Say I have three tables Type, Translation and Language
Type has a list
First
Second
Third
Translations will have values for that Type list in each of 2 langauges
Value1 german
Value1 french
Value2 german
Value2 french
etc…
Currently I am using a stored procedure that accepts the language to read from the Type table and overwrite the value if a translated value exists in the Translation table (if not just return the value from the Type table) … hope that makes sense.
The Stored Procedure I am using now would be something like this.
CREATE PROCEDURE [dbo].[GetTypesLocalized]
-- Add the parameters for the stored procedure here
@languageId int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
SELECT ISNULL(tr.Name, t.Name) AS Name,
FROM Type AS t
LEFT OUTER JOIN Translation AS tr ON
(tr.FK = t.Id AND tr.Type = 'type' AND tr.LanguageId = @languageId)
END
How would I represent that query in EF with linq syntax?
1 Answer