Click here to Skip to main content
15,910,277 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to all


I am new linq i want retrive multiple tables of data from sql using linq..



Just like in ado.net.


DS[0]-TABLE1
DS[1]-TABLE2
DS[2]-TABLE3


Thanks..

[edit]SHOUTING removed - OriginalGriff[/edit]
Posted
Updated 5-May-13 20:54pm
v2
Comments
OriginalGriff 6-May-13 2:54am    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalisation if you want to be taken seriously.

By joining tables you retrieve multiple tables of data using linq like below
C#
var results = (from a in a1
                join b in a2 on a.userID equals b.userID
                join c in a3 on a.userID equals c.userID
                select new
                {
                    a.userID,
                    a.firstName,
                    a.lastName,
                    b.Email,
                    c.Phone,
                    c.Address
                }).ToList();



Hope this helps
 
Share this answer
 
Comments
kallurirakesh 6-May-13 8:15am    
i dont wan't joining i want retive multiple tables data...
like
select * from table1
select * from table2
select * from table3

in ado.net we take dataset..
dataset[0]
dataset[1]
dataset[2]

how is it possible.
Try this:

C#
var result0 = from t1 in table1
              select t1;

var result1 = from t2 in table2
              select t2;

var result2 = from t3 in table3
              select t3;


For more info on LINQ, read this http://code.msdn.microsoft.com/101-LINQ-Samples-3fb9811b[^]
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900