Funky Sql Generated using SubSonic Simple Repository, LINQ and ASP.NET MVC

泪湿孤枕 提交于 2019-12-08 05:46:56

问题


I have the following code:

if (collection["Filter"] == "2") { 
   presentations = presentations.Where(x => x.Speaker.FirstName.StartsWith("B")).
   OrderBy(x => x.Speaker.FirstName);
}

this generates the following sql:

SELECT  [t0].[Description], [t0].[EventId], [t0].[Id], [t0].[PresentedOn], 
        [t0].[Slug], [t0].[SpeakerId], [t0].[Title], [t0].[Url]
FROM    [Presentations] AS t0
LEFT    OUTER JOIN [Speakers] AS t1 ON ([t1].[Id] = [t0].[Id])
WHERE   ([t1].[FirstName] LIKE 'B' + '%')
ORDER   BY [t1].[FirstName]

The problem is the join should be:

LEFT OUTER JOIN [Speakers] AS t1 ON ([t1].[Id] = [t0].[SpeakerId])

Any ideas how to correct this problem? Linked to ASP.NET MVC2 Linq Where Clause using StartsWith


回答1:


I don't think the SubSonic Linq provider is very 'mature'.



来源:https://stackoverflow.com/questions/3264435/funky-sql-generated-using-subsonic-simple-repository-linq-and-asp-net-mvc

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!