使用 SubSonic Simple Repository、LINQ 和 ASP.NET MVC 生成 Funky Sql
我有以下代码:
if (collection["Filter"] == "2") {
presentations = presentations.Where(x => x.Speaker.FirstName.StartsWith("B")).
OrderBy(x => x.Speaker.FirstName);
}
这会生成以下 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]
问题是联接应该是:
LEFT OUTER JOIN [Speakers] AS t1 ON ([t1].[Id] = [t0].[SpeakerId])
有什么想法如何纠正这个问题吗?链接到 使用 StartsWith 的 ASP.NET MVC2 LinqWhere 子句
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为 SubSonic Linq 提供商非常“成熟”。
I don't think the SubSonic Linq provider is very 'mature'.