Nested LINQ IQueryable and WCF WebApi -
Nested LINQ IQueryable and WCF WebApi -
i have method works expected.
class="lang-cs prettyprint-override">[webget] public iqueryable<buildjobmodel> getcustomers() { var context = new mydatacontext(); // ado.net entity info model var query = c in context.customers select new customermodel { id = c.id, name = c.name }; homecoming query; }
but when seek create more complex query this, doesn't work.
class="lang-cs prettyprint-override">[webget] public iqueryable<buildjobmodel> getcustomers() { var context = new mydatacontext(); // ado.net entity info model var query = c in context.customers select new customermodel { customerid = c.customerid, name = c.name, orders = o in c.orders select new ordermodel { orderid = o.orderid, details = o.details } }; homecoming query; }
the models this:
class="lang-cs prettyprint-override">public class customermodel { public int customerid { get; set; } public string name { get; set; } public ienumerable<ordermodel> orders { get; set; } } public class ordermodel { public int orderid { get; set; } public string details { get; set; } }
the exception:
cannot serialize fellow member proj.customermodel.logs of type system.collections.generic.ienumerable`1[[proj.ordermodel, proj, version=1.0.0.0, culture=neutral, publickeytoken=null]] because interface.
my goals:
i want able expose iqueryable interface. i want homecoming nested data. i want utilize own models, not ado.net entities i want nail database few queries possible (one best).
i recommend not exposing iqueryable
homecoming type of wcf service.
ideally, if want homecoming collections utilize array or generic list.
with respect list of goals:
can explain this? don't seeiqueryable
interface has nested data. you can still homecoming arrays or lists of your models you have improve command on performance if execute query locally , homecoming results instead update: have @ wcf info services - might able want.
wcf linq wcf-web-api
Comments
Post a Comment