c# - Adding Join to Existing LINQ Query -


i kindly helped this stack overflow question.

now i'm building query , need add joins other tables bring in names , descriptions etc.

my query this:

using (var ctx = new myentities())             {                 var pc = ctx.tblpostcodes.where(z => z.postcode == postcodeoutward)                         .select(x => new {postcodeid = x.postcodeid}).single();                  int pcid = pc.postcodeid;                  var q = ctx.tblprices.orderbydescending(x => x.cost)                 .where(c => c.postcodeid == pcid)                 .where(s => s.itemid < 18)                 .groupby(x => x.itemid)                 .select(g => new { g, count = g.count() })                 .tolist()                 .selectmany(t => t.g.select(b => b).zip(enumerable.range(1, t.count), (j, i) => new { j.itemid, j.cost, j.supplierid }));                  foreach (var in q)                 {                     sb.appendformat("itemid = {0}, cost = {1}, supplierid = {2}<hr/>", i.itemid,  i.cost, i.supplierid);                 }             } 

and i'm trying add following join:

.join(ctx.tblitems, => it.itemid, s => s.itemid, (it, s) => new { it, s }) 

but causes ambiguous invocation errors. ideas? need add 2 more inner joins. i'm hoping 1 right , other 2 easy (hopefully).

if use database first ef generates navigational properties dont have join.

if want able information outside query, use .include("navigational propertyname") command add 'joins' result in adding respective objects or list of objects query result.

 var q = ctx.tblprices.include("tblitems").orderbydescending(x => x.cost) 

better @ ef model find out property called...


Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -