使用DAL2访问数据:值不能为null.参数名称:con

Jur*_*ndw 6 sql data-access-layer dotnetnuke-module dotnetnuke-7

我正在尝试使用DotNetNuke中的DAL2访问数据.当我使用repository.Get()来获取某个表的所有字段时,我有时会收到此错误:

'价值不能为空.参数名称:con'

public IEnumerable<SitesProvince> GetAll()
{
     using (var ctx = DataContextContent.Instance())
     {
          var rep = ctx.GetRepository<SitesProvince>();
          return rep.Get();
     }
}
Run Code Online (Sandbox Code Playgroud)

模型:

[TableName("Sites_Province")]
[PrimaryKey("Sites_Province_No")]
[Cacheable("Sites_Province", CacheItemPriority.Default, 20)]
[Scope("Sites_Province_No")]
public class SitesProvince
{
    public int Sites_Province_No { get; set; }
    public string BU { get; set; }
    public string Province { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

可能是什么问题呢?在某些查询中,它有效,有些则没有,我认为方法之间没有任何区别.

我找到了这个,但我没有合同:http: //clraddins.codeplex.com/discussions/24568

Jur*_*ndw 12

我通过在模型中添加一个空构造函数来解决这个问题.现在一切正常.