mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Error message optimization
This commit is contained in:
@@ -167,7 +167,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.Dynamic)
|
else if (navObjectNameColumnInfo.Navigat.NavigatType == NavigateType.Dynamic)
|
||||||
{
|
{
|
||||||
Dynamic(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
|
Dynamic(list, selector, listItemEntity, navObjectNamePropety, navObjectNameColumnInfo,expression);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -378,18 +378,18 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Dynamic(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo)
|
private void Dynamic(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo,Expression expression)
|
||||||
{
|
{
|
||||||
var args = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments();
|
var args = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments();
|
||||||
if (args.Length == 0)
|
if (args.Length == 0)
|
||||||
{
|
{
|
||||||
DynamicOneToOne(list,selector,listItemEntity, navObjectNamePropety, navObjectNameColumnInfo);
|
DynamicOneToOne(list,selector,listItemEntity, navObjectNamePropety, navObjectNameColumnInfo,expression);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var navEntity = args[0];
|
var navEntity = args[0];
|
||||||
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
|
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
|
||||||
var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
|
var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
|
||||||
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"Dynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"自定义映射需要 MappingField ,例子: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())");
|
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"{expression} error,dynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"{expression} 解析出错,自定义映射需要 MappingField ,例子: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())");
|
||||||
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null)
|
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null)
|
||||||
{
|
{
|
||||||
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
|
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
|
||||||
@@ -409,12 +409,12 @@ namespace SqlSugar
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DynamicOneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo)
|
private void DynamicOneToOne(List<object> list, Func<ISugarQueryable<object>, List<object>> selector, EntityInfo listItemEntity, System.Reflection.PropertyInfo navObjectNamePropety, EntityColumnInfo navObjectNameColumnInfo,Expression expression)
|
||||||
{
|
{
|
||||||
var navEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType;
|
var navEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType;
|
||||||
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
|
var navEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(navEntity);
|
||||||
var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
|
var sqlObj = GetWhereSql(navObjectNameColumnInfo.Navigat.Name);
|
||||||
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"Dynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"自定义映射需要 MappingFields ,例子: Includes(it => it.Books.MappingFields(z=>z.studenId,()=>it.StudentId).ToList())");
|
Check.ExceptionEasy(sqlObj.MappingExpressions.IsNullOrEmpty(), $"{expression} error,dynamic need MappingField ,Demo: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())", $"{expression}解析出错, 自定义映射需要 MappingField ,例子: Includes(it => it.Books.MappingField(z=>z.studenId,()=>it.StudentId).ToList())");
|
||||||
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null)
|
if (list.Any() && navObjectNamePropety.GetValue(list.First()) == null)
|
||||||
{
|
{
|
||||||
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
|
MappingFieldsHelper<T> helper = new MappingFieldsHelper<T>();
|
||||||
|
Reference in New Issue
Block a user