Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

SQL Generation Issue

$
0
0

I'm using the 2015.1.225.1 version of data access and am passing a filter expression to validate if a group membership exists by examining the group ID which is a guid.  When I pass only one group, this works beautifully, but when I add an or expression, the generated SQL is missing a reference and returning invalid results:

Passing in:

"1 == 1 
&& (DateCreated >= DateTime.Parse(\"5/28/2016 12:00:00 AM\")) 
&& !Labels.Any(Name.Equals(\"Copied\")) 
&& (EventSubject.GroupAssignment.Any(GroupId.Equals(\"f6ee3591-1bfd-4941-8a17-da0c5dad3e23\")) 
    || EventSubject.GroupAssignment.Any(GroupId.Equals(\"881fc249-812d-43a2-bc26-b67ed9134324\")))"

 

Results In the or clause item not identifying the relation properly:

WHERE [ResourceId] = f.[ResourceId] 

should be WHERE d.[ResourceId] = f.[ResourceId] - that change would fix this completely, but I guess there must be something I'm doing that is causing a problem at a certain nesting level or something.  

Full Generated Query:

SELECT a.[EventId] AS COL1, 
       a.[Author] AS COL2, 
  a.[DateCreated] AS COL3, 
  a.[EventDate] AS COL4, 
  a.[EventImpact] AS COL5, 
  a.[EventImpact] AS COL6, 
  a.[EventScope] AS COL7, 
  a.[EventScope] AS COL8, 
  a.[EventType] AS COL9, 
  a.[EventType] AS COL10, 
  a.[EventVersion] AS COL11, 
  a.[LastModified] AS COL12, 
  a.[LastModifiedBy] AS COL13, 
  a.[Published] AS COL14, 
  a.[Author] AS COL15, 
  a.[LastModifiedBy] AS COL16, 
  a.[SubjectId] AS COL17, 
  a.[SubjectId] AS COL18, 
  a.[Summary] AS COL19 
FROM [EventTracker].[Events] a 
WHERE @p0 = 1 
AND a.[DateCreated] >= @p1 
AND not (EXISTS (SELECT 1 FROM [EventTracker].[Labels] b JOIN [EventTracker].[EventLabels] AS c ON (b.[Id] = c.[LabelId]) WHERE b.[Name] = 'Copied' AND c.[EventId] = a.[EventId])) 
AND EXISTS (SELECT 1234567 
           FROM [EventTracker].[Resource] d 
WHERE a.[SubjectId] = d.[ResourceId] AND ((EXISTS (SELECT 1 
                                                              FROM [EventTracker].[ResourcesInGroups] e 
  WHERE d.[ResourceId] = e.[ResourceId] 
AND e.[GroupId] = 'f6ee3591-1bfd-4941-8a17-da0c5dad3e23') 
  OR EXISTS (SELECT 1
             FROM [EventTracker].[ResourcesInGroups] f W
 WHERE [ResourceId] = f.[ResourceId] 
AND f.[GroupId] = '881fc249-812d-43a2-bc26-b67ed9134324')))) ORDER BY COL1 

 

I'm wondering if there is anything I can do to address this issues.  I've tried setting the filter expression to do a select().Count > 0 but that appears to result in the same generated query.  Any help pointing me in the right direction would be greatly appreciated!


Viewing all articles
Browse latest Browse all 84751

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>