I am using linq-to-entity to retrieve data dynamically and created a method as follows:
public List<object> getDynamicList(string tablename, List<string> colnames)
{
try
{
var query = DynamicQueryable.getDynamicData(dbcontext, tablename, colnames);
List<object> objQueryable = new List<object>();
object obj = query.AsQueryable();
objQueryable.Add(obj);
return objQueryable;
}
catch (Exception ex)
{
HandleError(ex);
}
}
this method in wcf service internally refers dynamic class given in LINQ samples (C:\Program Files开发者_JS百科 (x86)\Microsoft Visual Studio 10.0\Samples\1033)by MSVS2010.
when i am passing tablename,columns dynamically it does but on client side,while consuming that method it gives error- The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error. does wcf gives issue with iqueryable return type ?
please suggest......
You should look into WCF Data Services aka oData Services
Try using returning ToList() instead because Linq uses concept of Deffer Loading which means when at client side ToList or Result is being accessed it tries to connect to Server for getting result and it is where it would be getting failed. It is recommended when you use such kind of ORM you detach your objects and send result to client.
精彩评论