我需要绕过&#34;本地序列不能用于Linq To Sql&#34;限制,做左外连接。左外连接应返回IQueryable<T>
。
以下是一个示例代码:
public IQueryable<MyContainer> LeftOuter(IQueryable<MyContainer> query, List<Guid> myIds)
{
var leftOuterQuery =
from container in query
/* Exception --> */ from id in myIds.Where(myId => container.ContainerId == myId).DefaultIfEmpty()
select new { Container = container, Id = id };
return leftOuterQuery.Where(joined => joined.Container.ContainerId == null)
.Select(joined => joined.Container);
}