Update mapper

This commit is contained in:
sunkaixuan 2022-03-16 13:47:04 +08:00
parent 00ce7a94cd
commit 6cee4d547d
4 changed files with 53 additions and 0 deletions

View File

@ -102,6 +102,7 @@
<Compile Include="UnitTest\UCustom01.cs" />
<Compile Include="UnitTest\UCustom02.cs" />
<Compile Include="UnitTest\UCustom03.cs" />
<Compile Include="UnitTest\UCustom08.cs" />
<Compile Include="UnitTest\UCustom07.cs" />
<Compile Include="UnitTest\UCustom06.cs" />
<Compile Include="UnitTest\UCustom05.cs" />

View File

@ -31,6 +31,7 @@ namespace OrmTest
}
public static void Init()
{
UCustom08.Init();
UCustom07.Init();
UCustom01.Init();
UCustom02.Init();

View File

@ -0,0 +1,47 @@
using OrmTest.UnitTest.Models;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class UCustom08
{
public static void Init()
{
var db = NewUnitTest.Db;
db.CodeFirst.InitTables<Unitasfa1>();
db.CodeFirst.InitTables<Unitasfa1Item>();
db.Queryable<Unitasfa1>().Where(new List<IConditionalModel>
{
new ConditionalModel(){
ConditionalType=ConditionalType.In,
FieldName="id",
FieldValue="null"
}
}).ToList();
db.Insertable(new Unitasfa1() { Id = Guid.NewGuid() }).ExecuteCommand();
db.Insertable(new Unitasfa1() { Id = Guid.NewGuid(),ItemId=Guid.NewGuid() }).ExecuteCommand();
var list = db.Queryable<Unitasfa1>().Mapper(x => x.items, x => x.ItemId).ToList();
}
public class Unitasfa1
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; }
[SugarColumn(IsNullable = true)]
public Guid? ItemId { get; set; }
[SugarColumn(IsIgnore = true)]
public List<Unitasfa1Item> items { get; set; }
}
public class Unitasfa1Item
{
[SugarColumn(IsPrimaryKey = true)]
public Guid Id { get; set; }
}
}
}

View File

@ -2173,6 +2173,10 @@ namespace SqlSugar
Check.Exception(true, ".Mapper() parameter error");
}
List<string> inValues = entitys.Select(it => it.GetType().GetProperty(filedName).GetValue(it, null).ObjToString()).ToList();
if (inValues!=null&& inValues.Any()&&UtilMethods.GetUnderType(entitys.First().GetType().GetProperty(filedName).PropertyType) == UtilConstants.GuidType)
{
inValues = inValues.Select(x => x == "" ? "null" : x).Distinct().ToList();
}
List<IConditionalModel> wheres = new List<IConditionalModel>()
{
new ConditionalModel()