c# - How to assign list to generic list -


how can assign return result table generic list

this wcf service method.

public list<t> getapprovedstatelist(datetime effectivedate)     {         list<t> statelist = null;          using ( var db = new context())         {             statelist = (from in db.stateproductlist                          join b in db.states on a.stateid equals b.stateid                          a.effectivedate <= effectivedate                          select b).tolist();         }          return statelist;     } 

here entity class

public class entities {     public class state     {         public int stateid { get; set; }         public string statecode { get; set; }         public string statedescription { get; set; }       } 

here context

public class context : dbcontext, idisposable {     public context() : base("ecommconnectionstring")     {     }     public list<entities.state> states { get; set; }     public list<entities.product> products { get; set; }     public list<entities.stateproduct_list> stateproductlist { get; set; }   } 

how can return generic list wcf service then?

you don't, because list haven't isn't same type generic type. should returning list of type of values have.

public list<state> getapprovedstatelist(datetime effectivedate) {     using ( var db = new context())     {         return (from in db.stateproductlist                      join b in db.states on a.stateid equals b.stateid                      a.effectivedate <= effectivedate                      select b).tolist();     } } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -