New Posts New Posts RSS Feed: Inner/Left Join and Coalesce
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Inner/Left Join and Coalesce

 Post Reply Post Reply
Author
paul View Drop Down
Newbie
Newbie


Joined: 16-Sep-2010
Posts: 19
Post Options Post Options   Quote paul Quote  Post ReplyReply Direct Link To This Post Topic: Inner/Left Join and Coalesce
    Posted: 19-Aug-2012 at 6:12pm
I have a stored procedure I would like to convert to a linq expression. I've seen many EF examples but they don't seem very clean. I am curious if there is a better way of writing it using some DevForce tricks that would make it more efficient. I'd like to avoid selecting into a new object if I could but not necessary. 

My entities are 1:1 to my SQL tables and I do have an associations between my Regions and RegionLocalizeds entities.

Input param: @LanguageTypeId uniqueidentifier = null

SELECT 
    r.RegionId, 
    r.CountryId, 
    Coalesce(rl.FullDescription, rDefault.FullDescription) as FullDescription, 
    Coalesce(rl.StandardAbbreviation, rDefault.StandardAbbreviation )as StandardAbbreviation 
FROM dbo.Region r 
INNER JOIN RegionLocalized rDefault ON rDefault.RegionId = r.RegionId AND rDefault.LanguageTypeId = '00000000-0000-0000-0000-000000000000'
LEFT JOIN RegionLocalized rl ON r.RegionId = rl.RegionId AND rl.LanguageTypeId = @LanguageTypeId

Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2012 at 12:21pm
Hi Paul,
 
DevForce does not have any special feature when converting a Linq query from SQL.
There is a third party tool, Linqer, that might help you in the process of converting your queries.
 
Regards,
   Silvio.
Back to Top
paul View Drop Down
Newbie
Newbie


Joined: 16-Sep-2010
Posts: 19
Post Options Post Options   Quote paul Quote  Post ReplyReply Direct Link To This Post Posted: 20-Aug-2012 at 12:30pm
I wasn't asking to convert verbatim. I was curious if one of the DevForce professionals had a better way of writing as linq then the EF kludge I came up with. 
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down