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
I solved this problem by adding an empty constructor to my model. Now everything works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With