Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing data with DAL2: Value cannot be null.Parameter name: con

I'm trying to access data with DAL2 in DotNetNuke. When I use the repository.Get() to get all fields of a certain table I sometimes get this error:

'Value cannot be null. Parameter name: con'

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

Model:

[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; }
}

What could be the problem? In some queries it works and some don't and I don't see any difference between the methods.

I found this but I have no contracts: http://clraddins.codeplex.com/discussions/24568

like image 579
Jurgen Vandw Avatar asked Nov 12 '13 10:11

Jurgen Vandw


1 Answers

I solved this problem by adding an empty constructor to my model. Now everything works fine.

like image 200
Jurgen Vandw Avatar answered Sep 24 '22 00:09

Jurgen Vandw