This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, I have a project that is using both a CE provider and a SQL2008 provider. The CE provider is producing the SQL I would expect, however the SQL2008 provider is doing something quite odd. LINQ expression var defaultChannel = ( from x in UnitOfWork.Channels join y in UnitOfWork.ChannelAssignments on x.Id equals y.ChannelId where x.Protocol == Protocol.Smtp && y.AccountId == null && y.ApplicationId == null select x ).SingleOrDefault(); Resulting SQL CE SELECT t0.Id AS [t0.Id], t0.Details AS [t0.Details], t0.DisplayName AS [t0.DisplayName], t0.Guid AS [t0.Guid], t0.IsDefault AS [t0.IsDefault], t0.IsEnabled AS [t0.IsEnabled], t0.LifeTimeHours AS [t0.LifeTimeHours], t0.Priority AS [t0.Priority], t0.Protocol AS [t0.Protocol], t0.Type AS [t0.Type] FROM Channel t0 INNER JOIN ChannelAssignment t1 ON t0.Id = t1.ChannelId WHERE ((t0.Protocol = 'Smtp' AND t1.AccountId IS NULL) AND t1.ApplicationId IS NULL) Resulting SQL 2008 SELECT t0.* FROM ( SELECT t0.Id AS [t0.Id], t0.Details AS [t0.Details], t0.DisplayName AS [t0.DisplayName], t0.Guid AS [t0.Guid], t0.IsDefault AS [t0.IsDefault], t0.IsEnabled AS [t0.IsEnabled], t0.LifeTimeHours AS [t0.LifeTimeHours], t0.Priority AS [t0.Priority], t0.Protocol AS [t0.Protocol], t0.Type AS [t0.Type], ROW_NUMBER() OVER(ORDER BY t0.Id) as RowNumber FROM Channel t0 INNER JOIN ChannelAssignment t1 ON t0.Id = t1.ChannelId WHERE ((t0.Protocol = 'Smtp' AND t1.AccountId IS NULL) AND t1.ApplicationId IS NULL) ) t0 WHERE RowNumber <= 2 Is there anything that I have done wrong? It seems like it is doing some sort of paging? Any guidance would be appreciated. Thanks. |
|
|
You have specified the SingleOrDefault() operator. This requires us to check whether there is more than one result, and fail if there is. We therefore have to allow the database to return multiple results -- but we limit it to 2 to avoid the risk of getting thousands of records returned just so we can throw them away and raise an exception. |
|
|
Aha, that makes sense. And CE doesn't do that because it doesn't have an easy syntax for detecting that? |
|
|
It wasn't just that CE 3.5 didn't have an easy syntax -- I don't think it had it at all *grin*. CE 4 does, but you need to use a different provider to access CE 4 files.
|
|