mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-30 04:45:54 +08:00
Update mapper
This commit is contained in:
parent
00ce7a94cd
commit
6cee4d547d
@ -102,6 +102,7 @@
|
|||||||
<Compile Include="UnitTest\UCustom01.cs" />
|
<Compile Include="UnitTest\UCustom01.cs" />
|
||||||
<Compile Include="UnitTest\UCustom02.cs" />
|
<Compile Include="UnitTest\UCustom02.cs" />
|
||||||
<Compile Include="UnitTest\UCustom03.cs" />
|
<Compile Include="UnitTest\UCustom03.cs" />
|
||||||
|
<Compile Include="UnitTest\UCustom08.cs" />
|
||||||
<Compile Include="UnitTest\UCustom07.cs" />
|
<Compile Include="UnitTest\UCustom07.cs" />
|
||||||
<Compile Include="UnitTest\UCustom06.cs" />
|
<Compile Include="UnitTest\UCustom06.cs" />
|
||||||
<Compile Include="UnitTest\UCustom05.cs" />
|
<Compile Include="UnitTest\UCustom05.cs" />
|
||||||
|
@ -31,6 +31,7 @@ namespace OrmTest
|
|||||||
}
|
}
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
UCustom08.Init();
|
||||||
UCustom07.Init();
|
UCustom07.Init();
|
||||||
UCustom01.Init();
|
UCustom01.Init();
|
||||||
UCustom02.Init();
|
UCustom02.Init();
|
||||||
|
47
Src/Asp.Net/SqlServerTest/UnitTest/UCustom08.cs
Normal file
47
Src/Asp.Net/SqlServerTest/UnitTest/UCustom08.cs
Normal 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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2173,6 +2173,10 @@ namespace SqlSugar
|
|||||||
Check.Exception(true, ".Mapper() parameter error");
|
Check.Exception(true, ".Mapper() parameter error");
|
||||||
}
|
}
|
||||||
List<string> inValues = entitys.Select(it => it.GetType().GetProperty(filedName).GetValue(it, null).ObjToString()).ToList();
|
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>()
|
List<IConditionalModel> wheres = new List<IConditionalModel>()
|
||||||
{
|
{
|
||||||
new ConditionalModel()
|
new ConditionalModel()
|
||||||
|
Loading…
Reference in New Issue
Block a user