select of LINQ Dynamic Query is not working
I'm trying to use the LINQ Dynamic Query Library posted here -
http://weblogs.asp.net/scottgu/archive/2008/01/07/dynamic-linq-part-1-using-the-linq-dynamic-query-library.aspx
Based on this i created a generic method,where you can pass List as list
of selected columns.
public IList GetListByCriteriaQuery<T>(List<string> a_lstSelectColumns)
where T : class
{
IList lst= null;
try
{
if (a_lstSelectColumns!= null && a_lstSelectColumns.Count > 0)
{
var ccc=
dbContextOfSqlSupport123.CreateObjectSet<T>().Where(p =>
true)
.Select("new(" + string.Join(",",
a_lstSelectColumns) )") .OfType<T>().ToList();
}
}
catch (Exception ex)
{
return null;
}
return lst;
}
It gives me error as : Unable to cast the type 'DynamicClass1' to type ...
LINQ to Entities only supports casting Entity Data Model primitive types.
How i can return IList from this function ?
I got the same problem on provided link, but i find no working solution
there IQueryable to List<T>
No comments:
Post a Comment