Basic query of relational data-LinQ, and query by linq
As shown in the relational data, the LinQ statement is:
Var Query = from a in data. awhere. admin = input username &. pwd = input password (a model entity can be passed in) join B in data. B on. bid equals B. id into AB from r1 in AB. defaultIfEmpty () join c in data. C on r1.cid equals c. id into bc from r2 in bc. defaultIfEmpty () join d in data. D on r2.did equals d. id into cd from r3 in cd. defaultIfEmpty ()
Select new {// the id of table A; Id =. id, // here is the Name of table B; Name = r1.Name, Pro = r2.Pro, IpAdd = r3.IpAdd}; // convert it into an array; var list = Query. toList (); // list [0]. name indicates the Name of table B of the first data in the result of the entire LinQ query, and so on;
Note: r1 can output all data of table B... and so on;
R2 = table C;
R3 = table D;