odata - Populating IEnumerable<MyType> using Linq gives error "The specified type member is not supported in LINQ to Entities." -


i have model in fields directly mapped database table , expose through odata (v4). created 1 unmapped property ienumerable , map runtime in webapiconfig. model looks this

public class myclass { public int id {get;set;} public string name {get;set;}     [notmapped]  [foreignkey("mytype")] public virtual ienumerable<mytype> mycollection { { return context.mycollection.asqueryable(); } set { ;} }  } 

now when run , try results url http://localhost/odataservice/myclass(1)?$expand=mycollection, gives me error saying "message": "the specified type member 'test' not supported in linq entities. initializers, entity members, , entity navigation properties supported.

can point out how populate ienumerable runtime using linq?

thanks.

the error saying type doesn't map db entity. guess mytype c# type no db equivalent (seems said in question). ienumerable<mytype> fine when use it, needs in context of linq objects not linq entities or linq sql. if want populate ienumerable<mytype> @ runtime correct way of doing this;

  ienumerable<mytype> mytypes = somecollectionfrommydb.select(x => new mytype { fieldonmytype=x.columna, otherfield=x.columnb }); 

basically, should use select on linq entities collection project entities instances of mytype when need them.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -