Need to Convert This to LINQ
-
New to LINQ - I have an application that accesses the DB over a VPN and sometimes the with a slow connection I have a SQL statement that runs as one statement to the server and back... don't want to go back and fourth. I can do simple LINQ statements and I want to convert it to LINQ but need to keep as one statement and having trouble...
if exists (select * from MLEntries where UniversalID = sUID)
Select ml.UniversalID, sEmailaddr as Email, ml.CLID, ml.CN,c.Company,p.First_name, P.Last_name,
a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
from MLEntries ml
inner join people p on p.CLID = ml.CLID and p.CN = ml.CN
inner join address a on p.CLID = a.CLID and p.address_id = a.CN
inner join Client c on c.CLID = p.CLID and c.CN = 0
where ml.UniversalID = sUID
else
Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
from UF_tbl uf
inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
inner join address a on p.CLID = a.CLID and p.address_id = a.CN
inner join Client c on c.CLID = p.CLID and c.CN = 0
where Email_Addr = sEmailAddrThanks for any help dotnetme :confused:
dotnetme2
-
New to LINQ - I have an application that accesses the DB over a VPN and sometimes the with a slow connection I have a SQL statement that runs as one statement to the server and back... don't want to go back and fourth. I can do simple LINQ statements and I want to convert it to LINQ but need to keep as one statement and having trouble...
if exists (select * from MLEntries where UniversalID = sUID)
Select ml.UniversalID, sEmailaddr as Email, ml.CLID, ml.CN,c.Company,p.First_name, P.Last_name,
a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
from MLEntries ml
inner join people p on p.CLID = ml.CLID and p.CN = ml.CN
inner join address a on p.CLID = a.CLID and p.address_id = a.CN
inner join Client c on c.CLID = p.CLID and c.CN = 0
where ml.UniversalID = sUID
else
Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
from UF_tbl uf
inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
inner join address a on p.CLID = a.CLID and p.address_id = a.CN
inner join Client c on c.CLID = p.CLID and c.CN = 0
where Email_Addr = sEmailAddrThanks for any help dotnetme :confused:
dotnetme2
-
Nice resource, definitely adding it the bookmarks
I know the language. I've read a book. - _Madmatt
-
Nice resource, definitely adding it the bookmarks
I know the language. I've read a book. - _Madmatt
-
Hi thanks... I'm using VB... Found similar link to yours... As I said I'm new to LINQ so not sure if I'm approaching it the right way, but I thought would try and break it down into parts first... I tried serveral ways but here is one part I was trying to do. turning this SQL Statment
Select '' as UniversalID, sEmailaddr as Email, uf.CLID, uf.CN,c.Company,p.First_name, P.Last_name,
a.Address_Line_1 , a.Address_Line_2, a.City, a.State_Province, a.Country, a.Zip_Code, a.Phone_1
from UF_tbl uf
inner join people p on p.CLID = uf.CLID and p.CN = uf.CN
inner join address a on p.CLID = a.CLID and p.address_id = a.CN
inner join Client c on c.CLID = p.CLID and c.CN = 0
where Email_Addr = sEmailAddrinto this LINQ
Dim AllPeople = From uf In BDDB.User_Fields _
Group Join p In BDDB.Peoples On p.CLID Equals uf.CLID And p.CN Equals uf.CN Into pInfo = Group _
Group Join a In BDDB.Addresses On a.CLID Equals 'got stuck trying to join a to p???Or this LINQ
Dim Contact = From p In BDDB.Peoples _
Group Join uf In BDDB.User_Fields On uf.CLID Equals p.CLID And uf.CN Equals p.CN Into ufInfo = Group _
Group Join a In BDDB.Addresses On a.CLID Equals p.CLID And a.CN Equals p.Address_Id Into addrInfo = Group _
Group Join c In BDDB.Clients On c.CLID Equals p.CLID And c.CN Equals 0 Into CoInfo = Group _
Where 'uf.email_addr = sEmailAddr???Ok so they group into an alias but in the "Where" statement I can't get to the "uf" table anymore??? hmmm that's where they really lost me! Thanks for your Help...
dotnetme2