Select问题 返回

SqlSugar
10 321
该叫什么 Anye 发布于2022/1/17
悬赏:5 飞吻

这样可行吗?

AsQueryable().Select(a=>new People{
Name=a.Name,
Job=new JobClass{Company=a.Company,Work=a.Work}}
).ToList

我尝试了下,生成的语句有问题,是用法错了吗?


热忱回答10

  • fate sta fate sta VIP0
    2022/1/17

    提供实体类

    0 回复
  • Anye Anye VIP0
    2022/1/18

    @fate sta

    public class People{
        public string Name{get;set;}
        public JobClass Job{get;set;}
    }
    
    public class JobClass{
        public string Company{get;set;}
        public string Work{get;set;}
    }


    0 回复
  • fate sta fate sta VIP0
    2022/1/18

    @Anye:还少了一个类吧

    0 回复
  • fate sta fate sta VIP0
    2022/1/18

    可以重现了,后面版本会修复

    0 回复
  • fate sta fate sta VIP0
    2022/1/19

    发布了一个版本

    0 回复
  • Anye Anye VIP0
    2022/2/14

    @fate sta:这个bug解决了吗?现在报了An item with the same key has already been added. Key: Nullable`1)了,看堆栈好像识别成增加了

    0 回复
  • Anye Anye VIP0
    2022/2/14

       at System.ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException[T](T key)

       at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)

       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)

       at SqlSugar.BaseResolve.GetMappingColumns(Expression currentExpression)

       at SqlSugar.BaseResolve.ResolveNewExpressions(ExpressionParameter parameter, Expression item, String asName)

       at SqlSugar.MemberInitExpressionResolve.Select(MemberInitExpression expression, ExpressionParameter parameter, Boolean isSingle)

       at SqlSugar.MemberInitExpressionResolve..ctor(ExpressionParameter parameter)

       at SqlSugar.BaseResolve.Start()

       at SqlSugar.LambdaExpressionResolve..ctor(ExpressionParameter parameter)

       at SqlSugar.BaseResolve.Start()

       at SqlSugar.ExpressionContext.Resolve(Expression expression, ResolveExpressType resolveType)

       at SqlSugar.QueryBuilder.GetExpressionValue(Expression expression, ResolveExpressType resolveType)

       at SqlSugar.QueryBuilder.GetSelectValueByExpression()

       at SqlSugar.QueryBuilder.get_GetSelectValue()

       at SqlSugar.SqlServerQueryBuilder.ToSqlString()

       at SqlSugar.QueryableProvider`1._ToSql()

       at SqlSugar.QueryableProvider`1.MergeTable()


    0 回复
  • Anye Anye VIP0
    2022/2/14

    哦,不是,是字典增加出错了

    0 回复
  • Anye Anye VIP0
    2022/2/17

    好像是MergeTable()的问题

    0 回复
  • fate sta fate sta VIP0
    2022/2/17

    @Anye:提供完整用例

    0 回复