The error below occur when using ToObservableCollection() Any ideas why ?
An exception of type 'System.NotSupportedException' occurred in EntityFramework.SqlServer.dll but was not handled in user code
Additional information: The entity or complex type 'xxxx_DataModel.paytypes' cannot be constructed in a LINQ to Entities query.
var payTypes = (from payTypeTbl in Db.paytypes
where payTypeTbl.bActive == true
select new paytypes
{
iPayTypeId = payTypeTbl.iPayTypeId,
sImg = @"img\" + payTypeTbl.sImg,
sPayTypeName = payTypeTbl.sPayTypeName,
}
).ToObservableCollection();
public static class Extensions
{
public static ObservableCollection<T> ToObservableCollection<T>(this IEnumerable<T> col)
{
return new ObservableCollection<T>(col);
}
}
paytypes
a class defined in your source code base? - user1672994