c# - Linq to entities hard code list -


this view model

 public class procurementdisplaydata {     public string key { get; set;}     public string value { get; set;}   } 

how can hard code list. syntax inside query

 var query = (from u in context.jobs                          join q in context.quotations on u.quotationid equals q.quotationid                          join v in context.vessels on q.vesselid equals v.vesselid                          join c in context.customers on q.customerid equals c.customerid                          u.jobno == jobno                          select new list<procurementdisplaydata>                          {                             new { key = "a" ,value=u.jobno},                               new { key = "b" ,value=u.vessel}                            }).tolist();             return query; 

get jobno , vessel database. create lists in memory:

var query = u in context.jobs             join q in context.quotations on u.quotationid equals q.quotationid             join c in context.customers on q.customerid equals c.customerid             u.jobno == jobno             select new { u.jobno, u.vessel };  return query.asenumerable() // moves further processing memory             .select(x => new list<procurementdisplaydata> {                               new { key = "a", value = x.jobno },                               new { key = "b", value = x.vessel }                            }).tolist(); 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

angularjs - ng-repeat duplicating items after page reload -