InterviewSolution
| 1. |
How Do You Query In Entity Model When The Result Has A Join From From Different Database Other Than The Entity Model? |
|
Answer» E.g.: SELECT t1.c1, t2.c2 FROM table1 AS t1 JOIN table2 t2 ON t1.c1 = t2.c1 Following CODE snippet shows how to query when other databases are joined. Code: string query = "SELECT t1.c1, t2.c2 FROM table1 AS t1 JOIN table2 t2 ON t1.c1 = t2.c1"; using (var context = new SampleEntities()) { ObjectResult RECORDS = context.ExecuteStoreQuery(query); foreach (DbDataRecord record in records) { //Do whatever you WANT } } E.g.: SELECT t1.c1, t2.c2 FROM table1 AS t1 JOIN table2 t2 ON t1.c1 = t2.c1 Following code snippet shows how to query when other databases are joined. Code: string query = "SELECT t1.c1, t2.c2 FROM table1 AS t1 JOIN table2 t2 ON t1.c1 = t2.c1"; using (var context = new SampleEntities()) { ObjectResult records = context.ExecuteStoreQuery(query); foreach (DbDataRecord record in records) { //Do whatever you want } } |
|