Update mapper

This commit is contained in:
sunkaixuna 2022-01-10 19:33:22 +08:00
parent a6dd3c7f74
commit 9dce130127
2 changed files with 23 additions and 19 deletions

View File

@ -245,24 +245,24 @@ namespace OrmTest
UserType = 1 UserType = 1
}; };
db.Insertable(data).ExecuteCommand(); db.Insertable(data).ExecuteCommand();
var role = new SqlSugarDemo.RoleEntity() //var role = new SqlSugarDemo.RoleEntity()
{ //{
RoleId=Guid.NewGuid(), // RoleId=Guid.NewGuid(),
ManageAccount= Guid.NewGuid(), // ManageAccount= Guid.NewGuid(),
ManageOrg=Guid.NewGuid(), // ManageOrg=Guid.NewGuid(),
OrganizationId=Guid.NewGuid(), // OrganizationId=Guid.NewGuid(),
UnitPrice=1, // UnitPrice=1,
Quantity=1, // Quantity=1,
RoleName="", // RoleName="",
RoleType=1, // RoleType=1,
SortNum=1 // SortNum=1
}; //};
db.Insertable(role).ExecuteCommand(); //db.Insertable(role).ExecuteCommand();
db.Insertable(new SqlSugarDemo.UserRoleEntity() //db.Insertable(new SqlSugarDemo.UserRoleEntity()
{ //{
RoleId= role.RoleId, // RoleId= role.RoleId,
UserId=data.UserId // UserId=data.UserId
}).ExecuteCommand(); //}).ExecuteCommand();
var d111111111111 = db.Queryable<SqlSugarDemo.UserEntity>() var d111111111111 = db.Queryable<SqlSugarDemo.UserEntity>()
.Mapper<SqlSugarDemo.UserEntity, SqlSugarDemo.RoleEntity, SqlSugarDemo.UserRoleEntity>(it => ManyToMany.Config(it.UserId, it.RoleId)).InSingle(data.UserId); .Mapper<SqlSugarDemo.UserEntity, SqlSugarDemo.RoleEntity, SqlSugarDemo.UserRoleEntity>(it => ManyToMany.Config(it.UserId, it.RoleId)).InSingle(data.UserId);
} }

View File

@ -243,7 +243,11 @@ namespace SqlSugar
FieldValue=string.Join(",",mappingList.Select(z=>UtilMethods.GetPropertyValue(z,m_bPropertyName)).Distinct()) FieldValue=string.Join(",",mappingList.Select(z=>UtilMethods.GetPropertyValue(z,m_bPropertyName)).Distinct())
} }
}; };
var bList = this.Context.Queryable<BType>().Where(cons).ToList(); List<BType> bList = new List<BType>();
if (mappingList.Any())
{
bList=this.Context.Queryable<BType>().Where(cons).ToList();
}
//get result //get result
Dictionary<object, List<BType>> result = new Dictionary<object, List<BType>>(); Dictionary<object, List<BType>> result = new Dictionary<object, List<BType>>();