I have followed the SQL query and I would like to convert LINQ to SQL which I will use in Entity Framework 5.0
on internationalDesksList = _context.Subsections.Where to subdivision in internationalconnects from _context.InternationalDesks (= = InternationalDesks.EBALocationId == s.LocationId || internationalDesks.FELocationId == s.LocationId) .DefaultIfEmpty () where subsection Publishing IDU == 1 Select New {internationalDesks.Id, subsection.LocationId}; I have mentioned the following posts and answers though there is no luck.
When I tried this query, I got the following answer which is correct.
- Area parameter declaration @ p0 int = 1 - .. Select the EndRegion [t0] [Eid], [t1] [Eid] as [ID1] as [International0] from [t0] as the left outer [sub-section] as [t1] current (([ T0]. [FELocationId]) [[LocationId]) or (([t0]. [EBALocationId]) = [t1]. [LocationId]) where [T1]. [Publication ID] = @ P However, in Entity Framework 5 (DBCTX) it is not providing me with the correct query. When I checked in the SQL Profiler, all the columns were selected in the table. it's just that.
The following results are:
SELECT [extent1]. [ID] AS [ID], [Extent1]. [Details] AS [Details], [Extent1]. [PracticeAreaId] as [PracticeAreaId], [Extent1]. [LocationId] as [locationId], ... to [dbo]. [Subsection] As [Extent1] Do not know What could be the problem Please help me.
With LINQ you can not add left otter to some Boolean expression, only if Boolean is supported, You can generate Cross Include in this way:
on InternationalDesksList = _context.Subsections from subsection in _context.InternationalDesks from internationalDesks where subsection.PublicationId == 1 & amp; & Amp; (InternationalDesks.EBALocationId == subsection.LocationId || internationalDesks.FELocationId == Subsection.Position ID) Select new {internationalDesks.Id, subsection.LocationId}; EF 5 SQL will generate the following:
SELECT [extent1]. [ID] AS [ID], [Extant 2]. [Location ID] AS [[International DZX] AS [Extant 1] Cross Join [DBO]. [All section] AS [Extent 2] where (1 = [ext. 2]. [Publication ed]] and ([ext1]. [Ebolocation id] = [[location id] OR [extent1]. [FELocationId] = [Extent2] . [LocationId]) As you can see, only the required columns are selected. I also tested this query from LINQ on SQL - the following query has been created:
DECLARE @ p0 Int = 1 SELECT [t0]. [ID], [T1]. [T1] Where [[t1]] [PublicationId] = @ p0] and ([[t0]] [EBALocationId] = [[T0], [subdivision] as [t0] [EBALocationId] = [ T1]. [LocationId] or ([t0]. [FELocationId] = [T1]. [Location ID])
No comments:
Post a Comment