本文介绍了采用亚音速简单的资料库,LINQ和ASP.NET MVC的Sql质朴生成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code:

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

这将生成的SQL语句:

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])

任何想法如何解决这个问题?挂http://stackoverflow.com/questions/3262155/asp-net-mvc2-linq-where-clause-using-startswith

推荐答案

我不认为亚音速LINQ提供程序非常成熟。

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

这篇关于采用亚音速简单的资料库,LINQ和ASP.NET MVC的Sql质朴生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:22