Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# LINQ
I have sql server 2012 database with 12 tables (excluding look up tables). i am using entity frame work and trying to query. i am able to query a table:
ClientEntities dc = new ClientEntities();
     var query = from client1 in dc.CLIENTTable
                    where client1.CLIENT_ID == txtId.Text
                        select client1;
above works for 1 table but i need to do it for all the 12 tables. Is there a way to do it in loop
Posted 21-Jul-12 5:50am
Edited 21-Jul-12 6:45am
v2
Comments
WoodenLegNamedSmith at 21-Jul-12 12:20pm
   
http://itworksonmymachine.wordpress.com/2008/06/30/difference-between-linq-to-sql-and-the-entity-framework/
woutercx at 21-Jul-12 16:22pm
   
Do these other tables also have a CLIENT_ID? I'm trying to find out what it is exactly that you're trying to accomplish.
Wonde Tadesse at 21-Jul-12 16:47pm
   
If there is no relationships b/n the tables, There is no way to iterate a record for all tables with a single select statement.
Christian Amado at 21-Jul-12 17:25pm
   
Why you want to do something like that? I think is unnecessary.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Yes, if your other tables have keys that link them together, you can do it. Otherwise, you need to read them separately. You need to explain why you want to do this, and what you're trying to achieve. As it stands, it makes no sense at all.
 
You realise that you'll have to define your own type that contains the combined data ? You can't read the data from one table and store it in a type from another table, EF is all strongly typed. You can use var to create an anonymous type, of course.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 383
1 Richard Deeming 180
2 Sergey Alexandrovich Kryukov 171
3 Yogesh Kumar Tyagi 165
4 ChauhanAjay 156
0 Sergey Alexandrovich Kryukov 6,252
1 OriginalGriff 5,498
2 CPallini 2,473
3 Richard MacCutchan 1,627
4 Abhinav S 1,530


Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 21 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100