c# - LINQ Design time compile error -



c# - LINQ Design time compile error -

can please inform me right syntax below query?

i design time compile error origin @ "equals" keyword @ next spot:

&& a.applicationid equals ga.applicationid

with next error: "a query body must end select clause or grouping clause"

i understand error means, can't see syntax error is....

public static list<applicationconfigurations> getappconfigs() { seek { using (wmswebentities dbcontext = new wmswebentities()) { ienumerable<applicationconfigurations> myappconfigs = new ienumerable<applicationconfigurations>(); myappconfigs = (from in dbcontext.applicationconfigurations bring together ga in dbcontext.groupapplicationconfigurationslk on a.configurationid equals ga.configurationid && a.applicationid equals ga.applicationid bring together g in dbcontext.groups on g.groupnumber equals ga.groupnumber a.activeflag == true && ga.activeflag == true && g.activeflag == true select a.applicationconfigurations, g.groupnumber).tolist(); homecoming myappconfigs; } } grab (exception ex) { throw ex; } }

the reply this question has explanation of why cannot bring together on 2 fields in linq. suggests can either utilize anonymous type join, or can move 1 of conditions where clause. he's quick illustration set in linqpad illustrate using join 1 of conditions , where other, , using join anonymous type.

var applicationconfigs = new[] { new { applicationid = 1, configurationid = 1, name = "application #1" }, new { applicationid = 2, configurationid = 1, name = "application #2" }, new { applicationid = 3, configurationid = 2, name = "application #3" }, new { applicationid = 4, configurationid = 2, name = "application #4" } }; var groupapplicationconfigs = new[] { new { applicationid = 1, configurationid = 1, name = "group app config #1" }, new { applicationid = 1, configurationid = 1, name = "group app config #2" }, new { applicationid = 2, configurationid = 1, name = "group app config #3" }, new { applicationid = 3, configurationid = 1, name = "group app config #4" } }; //join + var q = in applicationconfigs bring together ga in groupapplicationconfigs on a.applicationid equals ga.applicationid a.configurationid == ga.configurationid select a; console.writeline(q); //anonymous type var r = in applicationconfigs bring together ga in groupapplicationconfigs on new { a.applicationid, a.configurationid } equals new { ga.applicationid, ga.configurationid } select a; console.writeline(r);

c# linq-to-sql entity-framework-4.3

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -