Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello
I cant convert this Query in SQL Server to LINQ

SQL
SELECT dbo.ReportType.Name
FROM   dbo.Center INNER JOIN
       dbo.SwitchType ON dbo.Center.ID = dbo.SwitchType.ID FULL JOIN
       dbo.ReportType ON dbo.Center.ID = dbo.ReportType.ID


Pleas help me .
Posted
Updated 18-Nov-12 2:11am
v3

1.Go to sql server and create a [VIEW] and join table's together.
2.Add View to LINQ to SQL
3.
C#
DataClasses1DataContext db = new DataClasses1DataContext();
ViewNameBindingSource.DataSource = db.ViewName.Where(c => c.Name=="KeySearch").Select(c=>c);
//ViewNameBindingSource BindingSource For ReportView 



2)Example By linq
C#
//linq to entities three table join query
var query = from p in db.QuizParticipants
            join points in db.ParticipantPoints on p.id 
            equals points.participantId into participantsGroup
            from po in participantsGroup
            join winners in db.Winners on p.id 
            equals winners.participantId into winnersGroup
            from w in winnersGroup
            where p.hasAttended == 1 && p.weeknumber == weeknumber
            select new
            {
                ParticipantId = p.id,
                HasAttended = p.hasAttended,
                Weeknumber = p.weeknumber, 
                UmbracoMemberId = p.umbMemberId,
                Points = po.points,
                HasWonFirstPrize = w.hasWonFirstPrize,
                HasWonVoucher = w.hasWonVoucher                                    
            };
 
Share this answer
 
v4
SQL
select * from PersonInfo
where code
in
(select a.Code from PersonInfo as a ,TradeElamieh as b
where a.Code=b.person1 and b.Actual=1 and (a.Investor_ID like'1338%' or a.Investor_ID like'1339%')
 and b.date>'2012-01-01' and a.Investor_ID IS NOT NULL)
 
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