English 中文(简体)
LINQ 离开Join 造成慢性错误。 核心
原标题:LINQ Left Join Causes error in SubSonic.Core

我正在使用最新版本的第三代和积极记录。 我正试图让一位左派加入《准则》。 它在SubSonic的某个地方出现错误。

车辆可能有多种图像,但不需要。 a 因此,加入是适当的。

这就是我所说的话。

var vehicle = from v in Vehicle.All()
              join dl in DealerLocation.All() on v.DealerLocationID equals dl.ID
              join vi in VehicleImage.All() on v.ID equals vi.VehicleID into VehicleImages
              from vij in VehicleImages.DefaultIfEmpty()
              && vij.IsPrimary
              select new
              {
                  v, vij.Image
              };

这是我发现的错误。

The expression of type  System.Linq.IQueryable`1[<>f__AnonymousType1`2[<>f__AnonymousType0`2[Project.Data.Vehicle,Project.Data.DealerLocation],System.Collections.Generic.IEnumerable`1[Project.Data.VehicleImage]]]  is not a sequence

这是 st痕。

   at SubSonic.Linq.Translation.QueryBinder.ConvertToSequence(Expression expr)
   at SubSonic.Linq.Translation.QueryBinder.VisitSequence(Expression source)
   at SubSonic.Linq.Translation.QueryBinder.BindSelectMany(Type resultType, Expression source, LambdaExpression collectionSelector, LambdaExpression resultSelector)
   at SubSonic.Linq.Translation.QueryBinder.VisitMethodCall(MethodCallExpression m)
   at SubSonic.Linq.Structure.ExpressionVisitor.Visit(Expression exp)
   at SubSonic.Linq.Structure.DbExpressionVisitor.Visit(Expression exp)
   at SubSonic.Linq.Translation.QueryBinder.Visit(Expression exp)
   at SubSonic.Linq.Translation.QueryBinder.Bind(QueryMapping mapping, Expression expression)
   at SubSonic.Linq.Structure.QueryMapping.Translate(Expression expression)
   at SubSonic.Linq.Structure.DbQueryProvider.Translate(Expression expression)
   at SubSonic.Linq.Structure.DbQueryProvider.GetExecutionPlan(Expression expression)
   at SubSonic.Linq.Structure.DbQueryProvider.Execute(Expression expression)
   at SubSonic.Linq.Structure.QueryProvider.System.Linq.IQueryProvider.Execute(Expression expression)
   at SubSonic.Linq.Structure.Query`1.GetEnumerator()
   at System.Linq.SystemCore_EnumerableDebugView`1.get_Items()

预先感谢任何见解。

问题回答

类似慢性诱杀。 http://github.com/subsonic/3.0/issues

看来,目前还没有这方面的固定办法。 一种简单的固定办法(但书)是形成一种观点,处理左边的结合,用缺省数据填充右边的空洞数据,并且分站仅加入这一观点。

我知道,这是可怕的,但现在却是一个固定点。 由于这一限制,我没有看到退学。 我确信很快会确定。

Trying Fluent Query can be a solution for now maybe. Something like:

var DB = new myDB();
IList<LiteObject> myLiteObject = DB.Select
    .From<Table1>()
    .InnerJoin<Table2>()
    .LeftOuterJoin<Table3>()
    .Where(Table1.IdColumn).IsEqualTo(1)
    .And(Table2.IdColumn).IsEqualTo(2)
    .ExecuteTypedList<LiteObject>();

在LiteObject包括所有表格中的领域。





相关问题
Debugging SQL in ASP.NET

private void BuildGridView2() { GridView1.DataSource = new Select() .From("NewsReleases") .Where("RelMonth").IsEqualTo(this.ddlAward.SelectedValue) .And("RelYear").IsEqualTo(this....

SubSonic Error with MySql CONVERT()

I has encountered conversion from integer to string with MySql+SubSonic3 (it generates wrong SQL query). After I found root of the problem in SubSonic sources and fixed it, everything works fine, but ...

SubSonic OpenExpression/CloseExpression

Hey All! I m trying to construct a query that is something like this: Where column = "value" AND column2 = "value" AND (column3 = "value" OR column4 = "value") I have this code: return new Select() ...

Grouping with SubSonic 3

I have the following table "GroupPriority": Id Group Priority 1 1 0 2 2 0 3 3 0 4 2 1 5 1 1 6 2 2 7 ...

Subsonic Linq guid problem

The construtor Void .ctor(System.Guid, Int32) is not supported. this error occured with the following statements: var Test = from r in db.UserRoles join p in db.UserPermissions on new { r....

热门标签