尝试使用 linq 在亚音速中进行左连接,但它似乎不起作用,我遇到了一个大错误。
我很确定查询是正确的,因为我已经用对象和 Linq2Sql 做了几次。
var post = from p in Post.All()
join q in Quote.All() on p.ID equals q.PostID into pq
where p.ID == id.Value
from qt in pq.DefaultIfEmpty()
select new {p, qt};
似乎亚音速无法从左连接 linq 查询中生成所需的 SQL。
我在这里做错了吗?有解决办法吗?
更新:我正在使用亚音速 3.0.0.2 这是我尝试使用亚音速左连接时遇到的错误
1[GetAQuote.Post]' cannot be used for parameter of type 'System.Linq.IQueryable
方法'System.Linq.IQueryable 1[<>f__AnonymousType2
2[GetAQuote.Post,System.Collections.Generic.IEnumerable 1[GetAQuote.Quote]]] GroupJoin[Post,Quote,Int32,<>f__AnonymousType2
2](System.Linq.IQueryable 1[GetAQuote.Post], System.Collections.Generic.IEnumerable
1[GetAQuote )的类型'System.Collections.Generic.IEnumerable 1[GetAQuote.Post]'的表达式.Quote], System.Linq.Expressions.Expression 1[System.Func
2[GetAQuote.Post,System.Int32]], System.Linq.Expressions.Expression 1[System.Func
2[GetAQuote.Quote,System.Int32]], System.Linq.Expressions.Expression 1[System.Func
3 [GetAQuote.Post,System.Collections.Generic.IEnumerable 1[GetAQuote.Quote],<>f__AnonymousType2
2[GetAQuote.Post,System.Collections.Generic.IEnumerable`1[GetAQuote.Quote]]]])'