mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-15 18:55:07 +08:00
Update .net core project
This commit is contained in:
@@ -22,6 +22,7 @@ namespace SqlSugar
|
||||
var mappingEntity = this._Context.EntityMaintenance.GetEntityInfo(mappingType);
|
||||
var mappingA = mappingEntity.Columns.FirstOrDefault(x => x.PropertyName == parentNavigateProperty.Navigat.MappingAId);
|
||||
var mappingB = mappingEntity.Columns.FirstOrDefault(x => x.PropertyName == parentNavigateProperty.Navigat.MappingBId);
|
||||
Check.ExceptionEasy(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||
var mappingPk = mappingEntity.Columns
|
||||
.Where(it => it.PropertyName != mappingA.PropertyName)
|
||||
.Where(it => it.PropertyName != mappingB.PropertyName)
|
||||
|
@@ -22,6 +22,7 @@ namespace SqlSugar
|
||||
var mappingEntity = this._Context.EntityMaintenance.GetEntityInfo(mappingType);
|
||||
var mappingA = mappingEntity.Columns.FirstOrDefault(x=>x.PropertyName== parentNavigateProperty.Navigat.MappingAId);
|
||||
var mappingB = mappingEntity.Columns.FirstOrDefault(x => x.PropertyName == parentNavigateProperty.Navigat.MappingBId);
|
||||
Check.ExceptionEasy(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||
var mappingPk = mappingEntity.Columns
|
||||
.Where(it => it.PropertyName != mappingA.PropertyName)
|
||||
.Where(it => it.PropertyName != mappingB.PropertyName)
|
||||
@@ -33,7 +34,6 @@ namespace SqlSugar
|
||||
.Where(it => !it.IsOnlyIgnoreInsert)
|
||||
.Where(it => !it.IsIgnore)
|
||||
.Where(it => !it.IsPrimarykey);
|
||||
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
||||
foreach (var item in parentList)
|
||||
{
|
||||
|
@@ -22,6 +22,7 @@ namespace SqlSugar
|
||||
var mappingEntity = this._Context.EntityMaintenance.GetEntityInfo(mappingType);
|
||||
var mappingA = mappingEntity.Columns.FirstOrDefault(x => x.PropertyName == parentNavigateProperty.Navigat.MappingAId);
|
||||
var mappingB = mappingEntity.Columns.FirstOrDefault(x => x.PropertyName == parentNavigateProperty.Navigat.MappingBId);
|
||||
Check.ExceptionEasy(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||
var mappingPk = mappingEntity.Columns
|
||||
.Where(it => it.PropertyName != mappingA.PropertyName)
|
||||
.Where(it => it.PropertyName != mappingB.PropertyName)
|
||||
@@ -33,7 +34,6 @@ namespace SqlSugar
|
||||
.Where(it => !it.IsPrimarykey)
|
||||
.Where(it => !it.IsOnlyIgnoreInsert)
|
||||
.Where(it => !it.IsIgnore);
|
||||
Check.Exception(mappingA == null || mappingB == null, $"Navigate property {name} error ", $"导航属性{name}配置错误");
|
||||
List<Dictionary<string, object>> mappgingTables = new List<Dictionary<string, object>>();
|
||||
var ids=new List<object>();
|
||||
foreach (var item in parentList)
|
||||
|
@@ -201,8 +201,10 @@ namespace SqlSugar
|
||||
var bEntity = navObjectNameColumnInfo.PropertyInfo.PropertyType.GetGenericArguments()[0];
|
||||
var bEntityInfo = this.Context.EntityMaintenance.GetEntityInfo(bEntity);
|
||||
var bPkColumn = bEntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey);
|
||||
Check.ExceptionEasy(bPkColumn==null, $"{bEntityInfo.EntityName} need primary key", $"{bEntityInfo.EntityName} 实体需要配置主键");
|
||||
this.Context.InitMappingInfo(bEntity);
|
||||
var listItemPkColumn = listItemEntity.Columns.Where(it => it.IsPrimarykey).FirstOrDefault();
|
||||
Check.ExceptionEasy(listItemPkColumn == null, $"{listItemEntity.EntityName} need primary key", $"{listItemEntity.EntityName} 实体需要配置主键");
|
||||
var ids = list.Select(it => it.GetType().GetProperty(listItemPkColumn.PropertyName).GetValue(it)).Select(it => it == null ? "null" : it).Distinct().ToList();
|
||||
var mappingEntity = this.Context.EntityMaintenance.GetEntityInfo(navObjectNameColumnInfo.Navigat.MappingType);
|
||||
var aColumn = mappingEntity.Columns.First(it => it.PropertyName == navObjectNameColumnInfo.Navigat.MappingAId);
|
||||
@@ -371,6 +373,7 @@ namespace SqlSugar
|
||||
if (navObjectNameColumnInfo.Navigat.Name2.HasValue())
|
||||
{
|
||||
listItemPkColumn = listItemEntity.Columns.Where(it => it.PropertyName== navObjectNameColumnInfo.Navigat.Name2).FirstOrDefault();
|
||||
Check.ExceptionEasy(listItemPkColumn == null, $"{navObjectNameColumnInfo.PropertyName} Navigate is error ", $"{navObjectNameColumnInfo.PropertyName}导航配置错误,可能顺序反了。");
|
||||
}
|
||||
var ids = list.Select(it => it.GetType().GetProperty(listItemPkColumn.PropertyName).GetValue(it)).Select(it => it == null ? "null" : it).Distinct().ToList();
|
||||
List<IConditionalModel> conditionalModels = new List<IConditionalModel>();
|
||||
|
@@ -99,9 +99,17 @@ namespace SqlSugar
|
||||
}
|
||||
var value = model.Args[1].MemberName;
|
||||
string inValueString = null;
|
||||
var isNvarchar = model.Args.Count == 3;
|
||||
if (inValues != null && inValues.Count > 0)
|
||||
{
|
||||
inValueString = inValues.ToArray().ToJoinSqlInVals();
|
||||
{
|
||||
if (isNvarchar&& model.Args[2].MemberValue.Equals(true))
|
||||
{
|
||||
inValueString = inValues.ToArray().ToJoinSqlInValsN();
|
||||
}
|
||||
else
|
||||
{
|
||||
inValueString = inValues.ToArray().ToJoinSqlInVals();
|
||||
}
|
||||
}
|
||||
if (inValueString.IsNullOrEmpty())
|
||||
{
|
||||
|
@@ -491,7 +491,7 @@ namespace SqlSugar
|
||||
//var property=item.Type.GetProperties().Where(it => it.Name == newExpressionInfo.l).First();
|
||||
//asName = GetAsName(item, newExpressionInfo.ShortName, property);
|
||||
parameter.Context.Result.Append(this.Context.GetAsString(
|
||||
this.Context.SqlTranslationLeft+asName + "." + newExpressionInfo.RightDbName+this.Context.SqlTranslationRight,
|
||||
this.Context.SqlTranslationLeft+asName + "." + newExpressionInfo.LeftNameName+this.Context.SqlTranslationRight,
|
||||
newExpressionInfo.ShortName+"."+newExpressionInfo.RightDbName
|
||||
));
|
||||
}
|
||||
|
@@ -149,8 +149,10 @@ namespace SqlSugar
|
||||
private MapperSql GetManyToManySql()
|
||||
{
|
||||
|
||||
var bPk = this.ProPertyEntity.Columns.First(it => it.IsPrimarykey == true).DbColumnName;
|
||||
var aPk = this.EntityInfo.Columns.First(it => it.IsPrimarykey == true).DbColumnName;
|
||||
var bPk = this.ProPertyEntity.Columns.FirstOrDefault(it => it.IsPrimarykey == true)?.DbColumnName;
|
||||
var aPk = this.EntityInfo.Columns.FirstOrDefault(it => it.IsPrimarykey == true)?.DbColumnName;
|
||||
Check.ExceptionEasy(aPk.IsNullOrEmpty(), $"{this.EntityInfo.EntityName}need primary key", $"{this.EntityInfo.EntityName}需要主键");
|
||||
Check.ExceptionEasy(bPk.IsNullOrEmpty(), $"{this.ProPertyEntity.EntityName}need primary key", $"{this.ProPertyEntity.EntityName}需要主键");
|
||||
MapperSql mapper = new MapperSql();
|
||||
var queryable = this.context.Queryable<object>();
|
||||
bPk = queryable.QueryBuilder.Builder.GetTranslationColumnName(bPk);
|
||||
|
14
Src/Asp.NetCore2/SqlSugar/Json2Sql/Enums/AsNameFormatType.cs
Normal file
14
Src/Asp.NetCore2/SqlSugar/Json2Sql/Enums/AsNameFormatType.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SqlSugar
|
||||
{
|
||||
public enum AsNameFormatType
|
||||
{
|
||||
Default = 0,
|
||||
NoConvert = 1
|
||||
}
|
||||
}
|
@@ -10,6 +10,7 @@ namespace SqlSugar
|
||||
ISugarQueryable<T> OrderBy(List<OrderByModel> models);
|
||||
ISugarQueryable<T> GroupBy(List<GroupByModel> models);
|
||||
ISugarQueryable<T> Select(List<SelectModel> models);
|
||||
ISugarQueryable<T> Select(List<SelectModel> models,AsNameFormatType type);
|
||||
ISugarQueryable<T> AS(string tableName, string shortName);
|
||||
ISugarQueryable<T> AddJoinInfo(string tableName, string shortName, IFuncModel models, JoinType type = JoinType.Left);
|
||||
ISugarQueryable<T> AddJoinInfo(List<JoinInfoParameter> joinInfoParameters);
|
||||
|
@@ -34,6 +34,10 @@ namespace SqlSugar
|
||||
{
|
||||
orderByModel.AsName = orderByModel.FiledName.ObjToString();
|
||||
}
|
||||
if (orderByModel.AsName.StartsWith(UtilConstants.ReplaceKey))
|
||||
{
|
||||
return orderByModel.AsName.Replace(UtilConstants.ReplaceKey, string.Empty);
|
||||
}
|
||||
return this.GetTranslationColumnName(orderByModel.AsName);
|
||||
}
|
||||
|
||||
|
@@ -57,6 +57,22 @@ namespace SqlSugar
|
||||
this.QueryBuilder.Parameters.AddRange(orderObj.Value);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> Select(List<SelectModel> models, AsNameFormatType type)
|
||||
{
|
||||
if (type == AsNameFormatType.NoConvert)
|
||||
{
|
||||
foreach (var model in models)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(model.AsName))
|
||||
{
|
||||
model.AsName = (UtilConstants.ReplaceKey + SqlBuilder.SqlTranslationLeft + model.AsName + SqlBuilder.SqlTranslationRight);
|
||||
model.AsName.ToCheckField();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Select(models);
|
||||
}
|
||||
public ISugarQueryable<T> Having(IFuncModel model)
|
||||
{
|
||||
var orderObj = this.SqlBuilder.FuncModelToSql(model);
|
||||
|
@@ -38,3 +38,13 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
namespace System.Collections.Generic
|
||||
{
|
||||
public static class EnumerableExtensions
|
||||
{
|
||||
public static bool Contains<T>(this IEnumerable<T> thisValue, T likeKey, bool isNvarchar)
|
||||
{
|
||||
return thisValue.Contains(likeKey);
|
||||
}
|
||||
}
|
||||
}
|
@@ -18,7 +18,17 @@ namespace SqlSugar
|
||||
return string.Join(",", array.Where(c => c != null).Select(it => it.ToSqlValue()));
|
||||
}
|
||||
}
|
||||
|
||||
public static string ToJoinSqlInValsN<T>(this T[] array)
|
||||
{
|
||||
if (array == null || array.Length == 0)
|
||||
{
|
||||
return ToSqlValue(string.Empty);
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.Join(",", array.Where(c => c != null).Select(it => "N"+it.ToSqlValue()));
|
||||
}
|
||||
}
|
||||
public static string ToSqlValue(this object value)
|
||||
{
|
||||
if (value!=null&& UtilConstants.NumericalTypes.Contains(value.GetType()))
|
||||
|
Reference in New Issue
Block a user