Print Page | Close Window

Inner/Left Join and Coalesce

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3585
Printed Date: 13-May-2026 at 3:48am


Topic: Inner/Left Join and Coalesce
Posted By: paul
Subject: Inner/Left Join and Coalesce
Date 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




Replies:
Posted By: sbelini
Date 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, http://www.sqltolinq.com/ - Linqer , that might help you in the process of converting your queries.
 
Regards,
   Silvio.


Posted By: paul
Date 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. 



Print Page | Close Window