mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-06-28 13:34:32 +08:00
Update Core
This commit is contained in:
parent
d4d04b4193
commit
d9544271ee
@ -16,21 +16,17 @@ namespace SqlSugar
|
|||||||
protected IDbMaintenance _DbMaintenance;
|
protected IDbMaintenance _DbMaintenance;
|
||||||
protected IDbConnection _DbConnection;
|
protected IDbConnection _DbConnection;
|
||||||
|
|
||||||
protected virtual SugarParameter[] GetParameters(object parameters, PropertyInfo[] propertyInfo,string sqlParameterKeyWord)
|
protected virtual SugarParameter[] GetParameters(object parameters, PropertyInfo[] propertyInfo, string sqlParameterKeyWord)
|
||||||
{
|
{
|
||||||
List<SugarParameter> result = new List<SugarParameter>();
|
List<SugarParameter> result = new List<SugarParameter>();
|
||||||
if (parameters != null)
|
if (parameters != null)
|
||||||
{
|
{
|
||||||
var entityType = parameters.GetType();
|
var entityType = parameters.GetType();
|
||||||
var isDictionary = entityType.IsIn(PubConst.DicArraySO, PubConst.DicArraySS);
|
var isDictionary = entityType.IsIn(UtilConstants.DicArraySO, UtilConstants.DicArraySS);
|
||||||
if (isDictionary)
|
if (isDictionary)
|
||||||
{
|
|
||||||
DictionaryToParameters(parameters, sqlParameterKeyWord, result, entityType);
|
DictionaryToParameters(parameters, sqlParameterKeyWord, result, entityType);
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType);
|
ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
@ -38,20 +34,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
PropertyInfo[] properties = null;
|
PropertyInfo[] properties = null;
|
||||||
if (propertyInfo != null)
|
if (propertyInfo != null)
|
||||||
{
|
|
||||||
properties = propertyInfo;
|
properties = propertyInfo;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
properties = entityType.GetProperties();
|
properties = entityType.GetProperties();
|
||||||
}
|
|
||||||
foreach (PropertyInfo properyty in properties)
|
foreach (PropertyInfo properyty in properties)
|
||||||
{
|
{
|
||||||
var value = properyty.GetValue(parameters, null);
|
var value = properyty.GetValue(parameters, null);
|
||||||
if (properyty.PropertyType.IsEnum())
|
if (properyty.PropertyType.IsEnum())
|
||||||
{
|
|
||||||
value = Convert.ToInt64(value);
|
value = Convert.ToInt64(value);
|
||||||
}
|
|
||||||
if (value == null || value.Equals(DateTime.MinValue)) value = DBNull.Value;
|
if (value == null || value.Equals(DateTime.MinValue)) value = DBNull.Value;
|
||||||
if (properyty.Name.ToLower().Contains("hierarchyid"))
|
if (properyty.Name.ToLower().Contains("hierarchyid"))
|
||||||
{
|
{
|
||||||
@ -69,7 +60,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected void DictionaryToParameters(object parameters, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
|
protected void DictionaryToParameters(object parameters, string sqlParameterKeyWord, List<SugarParameter> listParams, Type entityType)
|
||||||
{
|
{
|
||||||
if (entityType == PubConst.DicArraySO)
|
if (entityType == UtilConstants.DicArraySO)
|
||||||
{
|
{
|
||||||
var dictionaryParameters = (Dictionary<string, object>)parameters;
|
var dictionaryParameters = (Dictionary<string, object>)parameters;
|
||||||
var sugarParameters = dictionaryParameters.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
|
var sugarParameters = dictionaryParameters.Select(it => new SugarParameter(sqlParameterKeyWord + it.Key, it.Value));
|
||||||
|
@ -48,7 +48,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual void InitTables(string entitiesNamespace)
|
public virtual void InitTables(string entitiesNamespace)
|
||||||
{
|
{
|
||||||
var types = ReflectionCore.Load(entitiesNamespace).GetTypes();
|
var types = Assembly.Load(entitiesNamespace).GetTypes();
|
||||||
InitTables(types);
|
InitTables(types);
|
||||||
}
|
}
|
||||||
public virtual void InitTables(params string[] entitiesNamespaces)
|
public virtual void InitTables(params string[] entitiesNamespaces)
|
||||||
@ -115,7 +115,7 @@ namespace SqlSugar
|
|||||||
.Where(ec => !dbColumns.Any(dc => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
|
.Where(ec => !dbColumns.Any(dc => dc.DbColumnName.Equals(ec.OldDbColumnName, StringComparison.CurrentCultureIgnoreCase)))
|
||||||
.Where(ec =>
|
.Where(ec =>
|
||||||
dbColumns.Any(dc => dc.DbColumnName.Equals(ec.DbColumnName)
|
dbColumns.Any(dc => dc.DbColumnName.Equals(ec.DbColumnName)
|
||||||
&& ((ec.Length != dc.Length && !PubMethod.GetUnderType(ec.PropertyInfo).IsEnum() && PubMethod.GetUnderType(ec.PropertyInfo).IsIn(PubConst.StringType)) ||
|
&& ((ec.Length != dc.Length && !UtilMethods.GetUnderType(ec.PropertyInfo).IsEnum() && UtilMethods.GetUnderType(ec.PropertyInfo).IsIn(UtilConstants.StringType)) ||
|
||||||
ec.IsNullable != dc.IsNullable ||
|
ec.IsNullable != dc.IsNullable ||
|
||||||
IsSamgeType(ec, dc)))).ToList();
|
IsSamgeType(ec, dc)))).ToList();
|
||||||
var renameColumns = entityColumns
|
var renameColumns = entityColumns
|
||||||
@ -212,7 +212,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected virtual DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
protected virtual DbColumnInfo EntityColumnToDbColumn(EntityInfo entityInfo, string tableName, EntityColumnInfo item)
|
||||||
{
|
{
|
||||||
var propertyType = PubMethod.GetUnderType(item.PropertyInfo);
|
var propertyType = UtilMethods.GetUnderType(item.PropertyInfo);
|
||||||
var result = new DbColumnInfo()
|
var result = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
TableId = entityInfo.Columns.IndexOf(item),
|
TableId = entityInfo.Columns.IndexOf(item),
|
||||||
@ -223,7 +223,8 @@ namespace SqlSugar
|
|||||||
IsNullable = item.IsNullable,
|
IsNullable = item.IsNullable,
|
||||||
DefaultValue = item.DefaultValue,
|
DefaultValue = item.DefaultValue,
|
||||||
ColumnDescription = item.ColumnDescription,
|
ColumnDescription = item.ColumnDescription,
|
||||||
Length = item.Length
|
Length = item.Length,
|
||||||
|
DecimalDigits=item.DecimalDigits
|
||||||
};
|
};
|
||||||
if (!string.IsNullOrEmpty(item.DataType))
|
if (!string.IsNullOrEmpty(item.DataType))
|
||||||
{
|
{
|
||||||
@ -231,7 +232,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else if (propertyType.IsEnum())
|
else if (propertyType.IsEnum())
|
||||||
{
|
{
|
||||||
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? PubConst.LongType.Name : PubConst.IntType.Name);
|
result.DataType = this.Context.Ado.DbBind.GetDbTypeName(item.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -246,11 +247,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return ec.DataType != dc.DataType;
|
return ec.DataType != dc.DataType;
|
||||||
}
|
}
|
||||||
var propertyType = PubMethod.GetUnderType(ec.PropertyInfo);
|
var propertyType = UtilMethods.GetUnderType(ec.PropertyInfo);
|
||||||
var properyTypeName = string.Empty;
|
var properyTypeName = string.Empty;
|
||||||
if (propertyType.IsEnum())
|
if (propertyType.IsEnum())
|
||||||
{
|
{
|
||||||
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(ec.Length > 9 ? PubConst.LongType.Name : PubConst.IntType.Name);
|
properyTypeName = this.Context.Ado.DbBind.GetDbTypeName(ec.Length > 9 ? UtilConstants.LongType.Name : UtilConstants.IntType.Name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -45,32 +45,32 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
while (re.Read())
|
while (re.Read())
|
||||||
{
|
{
|
||||||
if (PubConst.DicOO == type)
|
if (UtilConstants.DicOO == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<object, object>(dataReader.GetValue(0), re.GetValue(1));
|
var kv = new KeyValuePair<object, object>(dataReader.GetValue(0), re.GetValue(1));
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<object, object>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<object, object>)));
|
||||||
}
|
}
|
||||||
else if (PubConst.DicIS == type)
|
else if (UtilConstants.DicIS == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<int, string>(dataReader.GetValue(0).ObjToInt(), re.GetValue(1).ObjToString());
|
var kv = new KeyValuePair<int, string>(dataReader.GetValue(0).ObjToInt(), re.GetValue(1).ObjToString());
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<int, string>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<int, string>)));
|
||||||
}
|
}
|
||||||
else if (PubConst.Dicii == type)
|
else if (UtilConstants.Dicii == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<int, int>(dataReader.GetValue(0).ObjToInt(), re.GetValue(1).ObjToInt());
|
var kv = new KeyValuePair<int, int>(dataReader.GetValue(0).ObjToInt(), re.GetValue(1).ObjToInt());
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<int, int>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<int, int>)));
|
||||||
}
|
}
|
||||||
else if (PubConst.DicSi == type)
|
else if (UtilConstants.DicSi == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<string, int>(dataReader.GetValue(0).ObjToString(), re.GetValue(1).ObjToInt());
|
var kv = new KeyValuePair<string, int>(dataReader.GetValue(0).ObjToString(), re.GetValue(1).ObjToInt());
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, int>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, int>)));
|
||||||
}
|
}
|
||||||
else if (PubConst.DicSo == type)
|
else if (UtilConstants.DicSo == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<string, object>(dataReader.GetValue(0).ObjToString(), re.GetValue(1));
|
var kv = new KeyValuePair<string, object>(dataReader.GetValue(0).ObjToString(), re.GetValue(1));
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, object>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, object>)));
|
||||||
}
|
}
|
||||||
else if (PubConst.DicSS == type)
|
else if (UtilConstants.DicSS == type)
|
||||||
{
|
{
|
||||||
var kv = new KeyValuePair<string, string>(dataReader.GetValue(0).ObjToString(), dataReader.GetValue(1).ObjToString());
|
var kv = new KeyValuePair<string, string>(dataReader.GetValue(0).ObjToString(), dataReader.GetValue(1).ObjToString());
|
||||||
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, string>)));
|
reval.Add((T)Convert.ChangeType(kv, typeof(KeyValuePair<string, string>)));
|
||||||
@ -98,21 +98,21 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
array[i] = Convert.ChangeType(re.GetValue(i), childType);
|
array[i] = Convert.ChangeType(re.GetValue(i), childType);
|
||||||
}
|
}
|
||||||
if (childType == PubConst.StringType)
|
if (childType == UtilConstants.StringType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToString()).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToString()).ToArray(), type));
|
||||||
else if (childType == PubConst.ObjType)
|
else if (childType == UtilConstants.ObjType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? null : (object)it).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? null : (object)it).ToArray(), type));
|
||||||
else if (childType == PubConst.BoolType)
|
else if (childType == UtilConstants.BoolType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToBool()).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToBool()).ToArray(), type));
|
||||||
else if (childType == PubConst.ByteType)
|
else if (childType == UtilConstants.ByteType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? 0 : (byte)it).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? 0 : (byte)it).ToArray(), type));
|
||||||
else if (childType == PubConst.DecType)
|
else if (childType == UtilConstants.DecType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToDecimal()).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToDecimal()).ToArray(), type));
|
||||||
else if (childType == PubConst.GuidType)
|
else if (childType == UtilConstants.GuidType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? Guid.Empty : (Guid)it).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? Guid.Empty : (Guid)it).ToArray(), type));
|
||||||
else if (childType == PubConst.DateType)
|
else if (childType == UtilConstants.DateType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? DateTime.MinValue : (DateTime)it).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it == DBNull.Value ? DateTime.MinValue : (DateTime)it).ToArray(), type));
|
||||||
else if (childType == PubConst.IntType)
|
else if (childType == UtilConstants.IntType)
|
||||||
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToInt()).ToArray(), type));
|
reval.Add((T)Convert.ChangeType(array.Select(it => it.ObjToInt()).ToArray(), type));
|
||||||
else
|
else
|
||||||
Check.Exception(true, ErrorMessage.NotSupportedArray);
|
Check.Exception(true, ErrorMessage.NotSupportedArray);
|
||||||
@ -135,7 +135,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reval.Add((T)Convert.ChangeType(re.GetValue(0),PubMethod.GetUnderType(type)));
|
reval.Add((T)Convert.ChangeType(re.GetValue(0),UtilMethods.GetUnderType(type)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ namespace SqlSugar
|
|||||||
#region Public methods
|
#region Public methods
|
||||||
public virtual string GetDbTypeName(string csharpTypeName)
|
public virtual string GetDbTypeName(string csharpTypeName)
|
||||||
{
|
{
|
||||||
if (csharpTypeName == PubConst.ByteArrayType.Name)
|
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
|
||||||
{
|
{
|
||||||
return "varbinary";
|
return "varbinary";
|
||||||
}
|
}
|
||||||
@ -143,7 +143,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
dbTypeName = dbTypeName.ToLower();
|
dbTypeName = dbTypeName.ToLower();
|
||||||
var propertyTypes = MappingTypes.Where(it => it.Key == dbTypeName);
|
var propertyTypes = MappingTypes.Where(it => it.Key == dbTypeName);
|
||||||
if (propertyTypes == null)
|
if (dbTypeName == "int32")
|
||||||
|
{
|
||||||
|
return "int";
|
||||||
|
}
|
||||||
|
else if (dbTypeName == "int64")
|
||||||
|
{
|
||||||
|
return "long";
|
||||||
|
}
|
||||||
|
else if (propertyTypes == null)
|
||||||
{
|
{
|
||||||
return "other";
|
return "other";
|
||||||
}
|
}
|
||||||
@ -173,7 +181,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return GetKeyValueList<T>(type, dataReader);
|
return GetKeyValueList<T>(type, dataReader);
|
||||||
}
|
}
|
||||||
else if (type.IsValueType() || type == PubConst.StringType)
|
else if (type.IsValueType() || type == UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
return GetValueTypeList<T>(type, dataReader);
|
return GetValueTypeList<T>(type, dataReader);
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
if (propertyInfo != null && propertyInfo.GetSetMethod() != null)
|
if (propertyInfo != null && propertyInfo.GetSetMethod() != null)
|
||||||
{
|
{
|
||||||
if (propertyInfo.PropertyType.IsClass() && propertyInfo.PropertyType != PubConst.ByteArrayType)
|
if (propertyInfo.PropertyType.IsClass() && propertyInfo.PropertyType != UtilConstants.ByteArrayType)
|
||||||
{
|
{
|
||||||
BindClass(generator, result, propertyInfo);
|
BindClass(generator, result, propertyInfo);
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ namespace SqlSugar
|
|||||||
IDbBind bind = Context.Ado.DbBind;
|
IDbBind bind = Context.Ado.DbBind;
|
||||||
bool isNullableType = false;
|
bool isNullableType = false;
|
||||||
MethodInfo method = null;
|
MethodInfo method = null;
|
||||||
Type bindPropertyType = PubMethod.GetUnderType(bindProperty, ref isNullableType);
|
Type bindPropertyType = UtilMethods.GetUnderType(bindProperty, ref isNullableType);
|
||||||
string dbTypeName = DataRecord.GetDataTypeName(ordinal);
|
string dbTypeName = DataRecord.GetDataTypeName(ordinal);
|
||||||
if (Regex.IsMatch(dbTypeName, @"\(.+\)"))
|
if (Regex.IsMatch(dbTypeName, @"\(.+\)"))
|
||||||
{
|
{
|
||||||
@ -186,15 +186,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType);
|
method = isNullableType ? getConvertEnum_Null.MakeGenericMethod(bindPropertyType) : getEnum.MakeGenericMethod(bindPropertyType);
|
||||||
}
|
}
|
||||||
else if (bindPropertyType == PubConst.IntType)
|
else if (bindPropertyType == UtilConstants.IntType)
|
||||||
{
|
{
|
||||||
method = isNullableType ? getConvertInt32 : getInt32;
|
method = isNullableType ? getConvertInt32 : getInt32;
|
||||||
}
|
}
|
||||||
else if (bindPropertyType == PubConst.StringType)
|
else if (bindPropertyType == UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
method = getString;
|
method = getString;
|
||||||
}
|
}
|
||||||
else if (bindPropertyType == PubConst.ByteArrayType)
|
else if (bindPropertyType == UtilConstants.ByteArrayType)
|
||||||
{
|
{
|
||||||
method = getValueMethod;
|
method = getValueMethod;
|
||||||
generator.Emit(OpCodes.Call, method);
|
generator.Emit(OpCodes.Call, method);
|
||||||
@ -254,11 +254,13 @@ namespace SqlSugar
|
|||||||
CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
|
CheckType(bind.DoubleThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||||
if (bindProperyTypeName == "double")
|
if (bindProperyTypeName == "double")
|
||||||
method = isNullableType ? getConvertDouble : getDouble;
|
method = isNullableType ? getConvertDouble : getDouble;
|
||||||
|
if(bindProperyTypeName=="single")
|
||||||
|
method = isNullableType ? getConvertFloat : getFloat;
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.Guid:
|
case CSharpDataType.Guid:
|
||||||
CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName);
|
CheckType(bind.GuidThrow, bindProperyTypeName, validPropertyName, propertyName);
|
||||||
if (bindProperyTypeName == "guid")
|
if (bindProperyTypeName == "guid")
|
||||||
method = isNullableType ? getConvertStringGuid : getStringGuid;
|
method = isNullableType ? getConvertGuid : getStringGuid;
|
||||||
break;
|
break;
|
||||||
case CSharpDataType.@byte:
|
case CSharpDataType.@byte:
|
||||||
if (bindProperyTypeName == "byte")
|
if (bindProperyTypeName == "byte")
|
||||||
@ -280,7 +282,7 @@ namespace SqlSugar
|
|||||||
method = getValueMethod;
|
method = getValueMethod;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (method == null && bindPropertyType == PubConst.StringType)
|
if (method == null && bindPropertyType == UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
method = getConvertString;
|
method = getConvertString;
|
||||||
}
|
}
|
||||||
@ -299,7 +301,7 @@ namespace SqlSugar
|
|||||||
var isAny = invalidTypes.Contains(bindProperyTypeName);
|
var isAny = invalidTypes.Contains(bindProperyTypeName);
|
||||||
if (isAny)
|
if (isAny)
|
||||||
{
|
{
|
||||||
throw new SqlSugarException(string.Format("{0} can't convert {1} to {2}", propertyName, validPropertyType, bindProperyTypeName));
|
throw new UtilExceptions(string.Format("{0} can't convert {1} to {2}", propertyName, validPropertyType, bindProperyTypeName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -27,10 +27,6 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static bool? GetConvertBoolean(this IDataRecord dr, int i)
|
public static bool? GetConvertBoolean(this IDataRecord dr, int i)
|
||||||
{
|
{
|
||||||
if (dr.IsDBNull(i))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var reval = dr.GetBoolean(i);
|
var reval = dr.GetBoolean(i);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
@ -57,11 +53,11 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static DateTime? GetConvertDateTime(this IDataRecord dr, int i)
|
public static DateTime? GetConvertDateTime(this IDataRecord dr, int i)
|
||||||
{
|
{
|
||||||
if (dr.IsDBNull(i))
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
var reval = dr.GetDateTime(i);
|
var reval = dr.GetDateTime(i);
|
||||||
|
if (reval == DateTime.MinValue)
|
||||||
|
{
|
||||||
|
return null; ;
|
||||||
|
}
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +185,7 @@ namespace SqlSugar
|
|||||||
#region Sqlite Extensions
|
#region Sqlite Extensions
|
||||||
public static Nullable<T> GetSqliteTypeNull<T>(this IDataReader dr, int i) where T : struct
|
public static Nullable<T> GetSqliteTypeNull<T>(this IDataReader dr, int i) where T : struct
|
||||||
{
|
{
|
||||||
var type = PubMethod.GetUnderType(typeof(T));
|
var type = UtilMethods.GetUnderType(typeof(T));
|
||||||
if (dr.IsDBNull(i))
|
if (dr.IsDBNull(i))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -205,27 +201,27 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private static T SqliteTypeConvert<T>(IDataReader dr, int i, Type type) where T : struct
|
private static T SqliteTypeConvert<T>(IDataReader dr, int i, Type type) where T : struct
|
||||||
{
|
{
|
||||||
if (type.IsIn(PubConst.IntType))
|
if (type.IsIn(UtilConstants.IntType))
|
||||||
{
|
{
|
||||||
return (T)((object)(dr.GetInt32(i)));
|
return (T)((object)(dr.GetInt32(i)));
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DateType)
|
else if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
return (T)Convert.ChangeType(Convert.ToDateTime(dr.GetString(i)), type);
|
return (T)Convert.ChangeType(Convert.ToDateTime(dr.GetString(i)), type);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DecType)
|
else if (type == UtilConstants.DecType)
|
||||||
{
|
{
|
||||||
return (T)Convert.ChangeType(dr.GetDecimal(i), type);
|
return (T)Convert.ChangeType(dr.GetDecimal(i), type);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DobType)
|
else if (type == UtilConstants.DobType)
|
||||||
{
|
{
|
||||||
return (T)Convert.ChangeType(dr.GetDouble(i), type);
|
return (T)Convert.ChangeType(dr.GetDouble(i), type);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
return (T)Convert.ChangeType(dr.GetBoolean(i), type);
|
return (T)Convert.ChangeType(dr.GetBoolean(i), type);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.GuidType)
|
else if (type == UtilConstants.GuidType)
|
||||||
{
|
{
|
||||||
string guidString = dr.GetString(i);
|
string guidString = dr.GetString(i);
|
||||||
string changeValue = guidString.IsNullOrEmpty() ? Guid.Empty.ToString() : guidString;
|
string changeValue = guidString.IsNullOrEmpty() ? Guid.Empty.ToString() : guidString;
|
||||||
|
@ -154,7 +154,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
classText = classText.Replace(DbFirstTemplate.KeyClassName, className);
|
classText = classText.Replace(DbFirstTemplate.KeyClassName, className);
|
||||||
classText = classText.Replace(DbFirstTemplate.KeyNamespace, this.Namespace);
|
classText = classText.Replace(DbFirstTemplate.KeyNamespace, this.Namespace);
|
||||||
classText = classText.Replace(DbFirstTemplate.KeyUsing, IsAttribute ? (this.UsingTemplate + "using " + PubConst.AssemblyName + ";\r\n") : this.UsingTemplate);
|
classText = classText.Replace(DbFirstTemplate.KeyUsing, IsAttribute ? (this.UsingTemplate + "using " + UtilConstants.AssemblyName + ";\r\n") : this.UsingTemplate);
|
||||||
classText = classText.Replace(DbFirstTemplate.KeyClassDescription, this.ClassDescriptionTemplate.Replace(DbFirstTemplate.KeyClassDescription, tableInfo.Description + "\r\n"));
|
classText = classText.Replace(DbFirstTemplate.KeyClassDescription, this.ClassDescriptionTemplate.Replace(DbFirstTemplate.KeyClassDescription, tableInfo.Description + "\r\n"));
|
||||||
classText = classText.Replace(DbFirstTemplate.KeySugarTable, IsAttribute ? string.Format(DbFirstTemplate.ValueSugarTable, tableInfo.Name) : null);
|
classText = classText.Replace(DbFirstTemplate.KeySugarTable, IsAttribute ? string.Format(DbFirstTemplate.ValueSugarTable, tableInfo.Name) : null);
|
||||||
if (columns.IsValuable())
|
if (columns.IsValuable())
|
||||||
|
@ -238,10 +238,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
string columnName = this.SqlBuilder.GetTranslationTableName(item.DbColumnName);
|
string columnName = this.SqlBuilder.GetTranslationTableName(item.DbColumnName);
|
||||||
string dataType = item.DataType;
|
string dataType = item.DataType;
|
||||||
string dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null;
|
string dataSize = GetSize(item);
|
||||||
if (item.Length>4000|| item.Length==-1) {
|
|
||||||
dataSize = string.Format("({0})","max");
|
|
||||||
}
|
|
||||||
string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
string nullType = item.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
||||||
string primaryKey = null;
|
string primaryKey = null;
|
||||||
string identity = item.IsIdentity ? this.CreateTableIdentity : null;
|
string identity = item.IsIdentity ? this.CreateTableIdentity : null;
|
||||||
@ -256,7 +253,7 @@ namespace SqlSugar
|
|||||||
string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
|
string columnName = this.SqlBuilder.GetTranslationColumnName(columnInfo.DbColumnName);
|
||||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
string dataType = columnInfo.DataType;
|
string dataType = columnInfo.DataType;
|
||||||
string dataSize = columnInfo.Length > 0 ? string.Format("({0})", columnInfo.Length) : null;
|
string dataSize = GetSize(columnInfo);
|
||||||
string nullType = columnInfo.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
string nullType = columnInfo.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
||||||
string primaryKey = null;
|
string primaryKey = null;
|
||||||
string identity = null;
|
string identity = null;
|
||||||
@ -268,7 +265,7 @@ namespace SqlSugar
|
|||||||
string columnName = this.SqlBuilder.GetTranslationTableName(columnInfo.DbColumnName);
|
string columnName = this.SqlBuilder.GetTranslationTableName(columnInfo.DbColumnName);
|
||||||
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
tableName = this.SqlBuilder.GetTranslationTableName(tableName);
|
||||||
string dataType = columnInfo.DataType;
|
string dataType = columnInfo.DataType;
|
||||||
string dataSize = columnInfo.Length > 0 ? string.Format("({0})", columnInfo.Length) : null;
|
string dataSize = GetSize(columnInfo);
|
||||||
string nullType = columnInfo.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
string nullType = columnInfo.IsNullable ? this.CreateTableNull : CreateTableNotNull;
|
||||||
string primaryKey = null;
|
string primaryKey = null;
|
||||||
string identity = null;
|
string identity = null;
|
||||||
@ -277,7 +274,25 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
protected virtual string GetCacheKey(string cacheKey)
|
protected virtual string GetCacheKey(string cacheKey)
|
||||||
{
|
{
|
||||||
return this.Context.CurrentConnectionConfig.DbType + "." + this.Context.Ado.Connection.Database +"."+ cacheKey;
|
return this.Context.CurrentConnectionConfig.DbType + "." + this.Context.Ado.Connection.Database + "." + cacheKey;
|
||||||
|
}
|
||||||
|
protected virtual string GetSize(DbColumnInfo item)
|
||||||
|
{
|
||||||
|
string dataSize = null;
|
||||||
|
var isMax = item.Length > 4000 || item.Length == -1;
|
||||||
|
if (isMax)
|
||||||
|
{
|
||||||
|
dataSize = item.Length > 0 ? string.Format("({0})", "max") : null;
|
||||||
|
}
|
||||||
|
else if (item.Length > 0 && item.DecimalDigits == 0)
|
||||||
|
{
|
||||||
|
dataSize = item.Length > 0 ? string.Format("({0})", item.Length) : null;
|
||||||
|
}
|
||||||
|
else if (item.Length > 0 && item.DecimalDigits > 0)
|
||||||
|
{
|
||||||
|
dataSize = item.Length > 0 ? string.Format("({0},{1})", item.Length, item.DecimalDigits) : null;
|
||||||
|
}
|
||||||
|
return dataSize;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -84,14 +84,14 @@ namespace SqlSugar
|
|||||||
var isFirst = deleteObjs.IndexOf(deleteObj) == 0;
|
var isFirst = deleteObjs.IndexOf(deleteObj) == 0;
|
||||||
if (isFirst)
|
if (isFirst)
|
||||||
{
|
{
|
||||||
orString.Append(DeleteBuilder.WhereInOrTemplate + PubConst.Space);
|
orString.Append(DeleteBuilder.WhereInOrTemplate + UtilConstants.Space);
|
||||||
}
|
}
|
||||||
int i = 0;
|
int i = 0;
|
||||||
StringBuilder andString = new StringBuilder();
|
StringBuilder andString = new StringBuilder();
|
||||||
foreach (var primaryField in primaryFields)
|
foreach (var primaryField in primaryFields)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
andString.Append(DeleteBuilder.WhereInAndTemplate + PubConst.Space);
|
andString.Append(DeleteBuilder.WhereInAndTemplate + UtilConstants.Space);
|
||||||
var entityPropertyName = this.Context.EntityProvider.GetPropertyName<T>(primaryField);
|
var entityPropertyName = this.Context.EntityProvider.GetPropertyName<T>(primaryField);
|
||||||
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName == entityPropertyName);
|
var columnInfo = EntityInfo.Columns.Single(it => it.PropertyName == entityPropertyName);
|
||||||
var entityValue = columnInfo.PropertyInfo.GetValue(deleteObj, null);
|
var entityValue = columnInfo.PropertyInfo.GetValue(deleteObj, null);
|
||||||
@ -115,6 +115,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public IDeleteable<T> Where(T deleteObj)
|
public IDeleteable<T> Where(T deleteObj)
|
||||||
{
|
{
|
||||||
|
Check.Exception(GetPrimaryKeys().IsNullOrEmpty(), "Where(entity) Primary key required");
|
||||||
Where(new List<T>() { deleteObj });
|
Where(new List<T>() { deleteObj });
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@ namespace SqlSugar
|
|||||||
column.Length = sugarColumn.Length;
|
column.Length = sugarColumn.Length;
|
||||||
column.OldDbColumnName = sugarColumn.OldColumnName;
|
column.OldDbColumnName = sugarColumn.OldColumnName;
|
||||||
column.DataType = sugarColumn.ColumnDataType;
|
column.DataType = sugarColumn.ColumnDataType;
|
||||||
|
column.DecimalDigits = sugarColumn.DecimalDigits;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -174,7 +174,7 @@ namespace SqlSugar
|
|||||||
Value = column.PropertyInfo.GetValue(item, null),
|
Value = column.PropertyInfo.GetValue(item, null),
|
||||||
DbColumnName = GetDbColumnName(column.PropertyName),
|
DbColumnName = GetDbColumnName(column.PropertyName),
|
||||||
PropertyName = column.PropertyName,
|
PropertyName = column.PropertyName,
|
||||||
PropertyType = PubMethod.GetUnderType(column.PropertyInfo),
|
PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
|
||||||
TableId = i
|
TableId = i
|
||||||
};
|
};
|
||||||
if (columnInfo.PropertyType.IsEnum())
|
if (columnInfo.PropertyType.IsEnum())
|
||||||
|
@ -11,5 +11,6 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
protected ILambdaExpressions _LambdaExpressions;
|
protected ILambdaExpressions _LambdaExpressions;
|
||||||
protected bool _RestoreMapping = true;
|
protected bool _RestoreMapping = true;
|
||||||
|
protected int _InQueryableIndex = 100;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ namespace SqlSugar
|
|||||||
public virtual ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null)
|
public virtual ISugarQueryable<T> Where<T2>(string whereString, object whereObj = null)
|
||||||
{
|
{
|
||||||
var whereValue = QueryBuilder.WhereInfos;
|
var whereValue = QueryBuilder.WhereInfos;
|
||||||
whereValue.Add(SqlBuilder.AppendWhereOrAnd(whereValue.Count == 0, whereString + PubConst.Space));
|
whereValue.Add(SqlBuilder.AppendWhereOrAnd(whereValue.Count == 0, whereString + UtilConstants.Space));
|
||||||
if (whereObj != null)
|
if (whereObj != null)
|
||||||
QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(whereObj));
|
QueryBuilder.Parameters.AddRange(Context.Ado.GetParameters(whereObj));
|
||||||
return this;
|
return this;
|
||||||
@ -259,19 +259,12 @@ namespace SqlSugar
|
|||||||
return In(expression, inValues.ToArray());
|
return In(expression, inValues.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression) {
|
public virtual ISugarQueryable<T> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
var sqlObj=childQueryExpression.ToSql();
|
{
|
||||||
if (sqlObj.Value.IsValuable()) {
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
|
_InQueryable(expression, sqlObj);
|
||||||
}
|
|
||||||
var isSingle = QueryBuilder.IsSingle();
|
|
||||||
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
|
||||||
var fieldName = lamResult.GetResultString();
|
|
||||||
var whereSql = string.Format(this.QueryBuilder.InTemplate, fieldName, sqlObj.Key);
|
|
||||||
this.QueryBuilder.WhereInfos.Add(SqlBuilder.AppendWhereOrAnd(this.QueryBuilder.WhereInfos.IsNullOrEmpty(),whereSql));
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
public virtual ISugarQueryable<T> OrderBy(string orderFileds)
|
||||||
{
|
{
|
||||||
var orderByValue = QueryBuilder.OrderByValue;
|
var orderByValue = QueryBuilder.OrderByValue;
|
||||||
@ -410,6 +403,14 @@ namespace SqlSugar
|
|||||||
QueryBuilder.SelectValue = selectValue;
|
QueryBuilder.SelectValue = selectValue;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public virtual ISugarQueryable<T> MergeTable()
|
||||||
|
{
|
||||||
|
Check.Exception(this.QueryBuilder.SelectValue.IsNullOrEmpty(), "MergeTable need to use Select(it=>new{}) Method .");
|
||||||
|
Check.Exception(this.QueryBuilder.Skip > 0 || this.QueryBuilder.Take > 0, "MergeTable Queryable cannot Take Skip OrderBy PageToList ");
|
||||||
|
var sql = QueryBuilder.ToSqlString();
|
||||||
|
var tableName =this.SqlBuilder.GetPackTable (sql, "MergeTable");
|
||||||
|
return this.Context.Queryable<ExpandoObject>().AS(tableName).Select<T>("*");
|
||||||
|
}
|
||||||
|
|
||||||
public virtual int Count()
|
public virtual int Count()
|
||||||
{
|
{
|
||||||
@ -576,7 +577,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var isSingle = QueryBuilder.IsSingle();
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
OrderBy(lamResult.GetResultString() + PubConst.Space + type.ToString().ToUpper());
|
OrderBy(lamResult.GetResultString() + UtilConstants.Space + type.ToString().ToUpper());
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
protected ISugarQueryable<T> _GroupBy(Expression expression)
|
protected ISugarQueryable<T> _GroupBy(Expression expression)
|
||||||
@ -675,6 +676,21 @@ namespace SqlSugar
|
|||||||
SetContextModel(result, entityType);
|
SetContextModel(result, entityType);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
protected void _InQueryable(Expression<Func<T, object>> expression, KeyValuePair<string, List<SugarParameter>> sqlObj)
|
||||||
|
{
|
||||||
|
string sql = sqlObj.Key;
|
||||||
|
if (sqlObj.Value.IsValuable())
|
||||||
|
{
|
||||||
|
this.SqlBuilder.RepairReplicationParameters(ref sql,sqlObj.Value.ToArray(),100);
|
||||||
|
this.QueryBuilder.Parameters.AddRange(sqlObj.Value);
|
||||||
|
}
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
var whereSql = string.Format(this.QueryBuilder.InTemplate, fieldName, sql);
|
||||||
|
this.QueryBuilder.WhereInfos.Add(SqlBuilder.AppendWhereOrAnd(this.QueryBuilder.WhereInfos.IsNullOrEmpty(), whereSql));
|
||||||
|
base._InQueryableIndex += 100;
|
||||||
|
}
|
||||||
|
|
||||||
protected List<string> GetPrimaryKeys()
|
protected List<string> GetPrimaryKeys()
|
||||||
{
|
{
|
||||||
@ -716,7 +732,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (result.IsValuable())
|
if (result.IsValuable())
|
||||||
{
|
{
|
||||||
if (entityType.GetTypeInfo().BaseType.IsValuable() && entityType.GetTypeInfo().BaseType == PubConst.ModelType)
|
if (entityType.GetTypeInfo().BaseType.IsValuable() && entityType.GetTypeInfo().BaseType == UtilConstants.ModelType)
|
||||||
{
|
{
|
||||||
foreach (var item in result)
|
foreach (var item in result)
|
||||||
{
|
{
|
||||||
@ -829,6 +845,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T3
|
#region T3
|
||||||
@ -956,6 +997,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T4
|
#region T4
|
||||||
@ -1104,6 +1170,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T5
|
#region T5
|
||||||
@ -1278,6 +1369,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T6
|
#region T6
|
||||||
@ -1478,6 +1594,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T7
|
#region T7
|
||||||
@ -1705,6 +1846,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T8
|
#region T8
|
||||||
@ -1958,6 +2124,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T9
|
#region T9
|
||||||
@ -2234,6 +2425,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T10
|
#region T10
|
||||||
@ -2534,6 +2750,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T11
|
#region T11
|
||||||
@ -2859,6 +3100,31 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues)
|
||||||
|
{
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression)
|
||||||
|
{
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region T12
|
#region T12
|
||||||
@ -3209,6 +3475,28 @@ namespace SqlSugar
|
|||||||
return _Avg<TResult>(expression);
|
return _Avg<TResult>(expression);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues) {
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues) {
|
||||||
|
var isSingle = QueryBuilder.IsSingle();
|
||||||
|
var lamResult = QueryBuilder.GetExpressionValue(expression, isSingle ? ResolveExpressType.FieldSingle : ResolveExpressType.FieldMultiple);
|
||||||
|
var fieldName = lamResult.GetResultString();
|
||||||
|
In(fieldName, inValues);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression) {
|
||||||
|
var sqlObj = childQueryExpression.ToSql();
|
||||||
|
_InQueryable(expression, sqlObj);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_WhereInfos = PubMethod.IsNullReturnNew(_WhereInfos);
|
_WhereInfos = UtilMethods.IsNullReturnNew(_WhereInfos);
|
||||||
return _WhereInfos;
|
return _WhereInfos;
|
||||||
}
|
}
|
||||||
set { _WhereInfos = value; }
|
set { _WhereInfos = value; }
|
||||||
@ -83,10 +83,10 @@ namespace SqlSugar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var result = Builder.GetTranslationTableName(EntityInfo.EntityName);
|
var result = Builder.GetTranslationTableName(EntityInfo.EntityName);
|
||||||
result += PubConst.Space;
|
result += UtilConstants.Space;
|
||||||
if (this.TableWithString.IsValuable())
|
if (this.TableWithString.IsValuable())
|
||||||
{
|
{
|
||||||
result += TableWithString + PubConst.Space;
|
result += TableWithString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var isFirst = i == 0;
|
var isFirst = i == 0;
|
||||||
whereString += isFirst ? "WHERE " : "AND ";
|
whereString += isFirst ? "WHERE " : "AND ";
|
||||||
whereString += (item + PubConst.Space);
|
whereString += (item + UtilConstants.Space);
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
return whereString;
|
return whereString;
|
||||||
|
@ -86,10 +86,10 @@ namespace SqlSugar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var result = Builder.GetTranslationTableName(EntityInfo.EntityName);
|
var result = Builder.GetTranslationTableName(EntityInfo.EntityName);
|
||||||
result += PubConst.Space;
|
result += UtilConstants.Space;
|
||||||
if (this.TableWithString.IsValuable())
|
if (this.TableWithString.IsValuable())
|
||||||
{
|
{
|
||||||
result += TableWithString + PubConst.Space;
|
result += TableWithString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type = value.GetType();
|
var type = value.GetType();
|
||||||
if (type == PubConst.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < Convert.ToDateTime("1900-1-1"))
|
||||||
@ -169,11 +169,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Convert.ToInt64(value);
|
return Convert.ToInt64(value);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
return value.ObjToBool() ? "1" : "0";
|
return value.ObjToBool() ? "1" : "0";
|
||||||
}
|
}
|
||||||
else if (type == PubConst.StringType || type == PubConst.ObjType)
|
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
return "N'" + value.ToString().ToSqlFilter() + "'";
|
return "N'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_EasyJoinInfos = PubMethod.IsNullReturnNew(_EasyJoinInfos);
|
_EasyJoinInfos = UtilMethods.IsNullReturnNew(_EasyJoinInfos);
|
||||||
return _EasyJoinInfos;
|
return _EasyJoinInfos;
|
||||||
}
|
}
|
||||||
set { _EasyJoinInfos = value; }
|
set { _EasyJoinInfos = value; }
|
||||||
@ -62,7 +62,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_JoinQueryInfos = PubMethod.IsNullReturnNew(_JoinQueryInfos);
|
_JoinQueryInfos = UtilMethods.IsNullReturnNew(_JoinQueryInfos);
|
||||||
return _JoinQueryInfos;
|
return _JoinQueryInfos;
|
||||||
}
|
}
|
||||||
set { _JoinQueryInfos = value; }
|
set { _JoinQueryInfos = value; }
|
||||||
@ -72,7 +72,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_WhereInfos = PubMethod.IsNullReturnNew(_WhereInfos);
|
_WhereInfos = UtilMethods.IsNullReturnNew(_WhereInfos);
|
||||||
return _WhereInfos;
|
return _WhereInfos;
|
||||||
}
|
}
|
||||||
set { _WhereInfos = value; }
|
set { _WhereInfos = value; }
|
||||||
@ -140,7 +140,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "ORDER BY GETDATE() ";
|
return "ORDER BY "+this.Builder.SqlDateNow+" ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual string OrderByTemplate
|
public virtual string OrderByTemplate
|
||||||
@ -236,9 +236,9 @@ namespace SqlSugar
|
|||||||
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString);
|
var rowNumberString = string.Format(",ROW_NUMBER() OVER({0}) AS RowIndex ", GetOrderByString);
|
||||||
string groupByValue = GetGroupByString + HavingInfos;
|
string groupByValue = GetGroupByString + HavingInfos;
|
||||||
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
|
string orderByValue = (!isRowNumber && this.OrderByValue.IsValuable()) ? GetOrderByString : null;
|
||||||
if (this.IsCount) { orderByValue = null; }
|
if (this.IsCount) { orderByValue = null; this.OrderByValue = oldOrderBy; }
|
||||||
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
|
sql.AppendFormat(SqlTemplate, GetSelectValue, GetTableNameString, GetWhereValueString, groupByValue, orderByValue);
|
||||||
sql.Replace("{$:OrderByString:$}", isRowNumber ? (this.IsCount ? null : rowNumberString) : null);
|
sql.Replace(UtilConstants.OrderReplace, isRowNumber ? (this.IsCount ? null : rowNumberString) : null);
|
||||||
if (this.IsCount) { return sql.ToString(); }
|
if (this.IsCount) { return sql.ToString(); }
|
||||||
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
|
var result = ToPageSql(sql.ToString(), this.Take, this.Skip);
|
||||||
if (ExternalPageIndex > 0)
|
if (ExternalPageIndex > 0)
|
||||||
@ -314,9 +314,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return string.Format(
|
return string.Format(
|
||||||
this.JoinTemplate,
|
this.JoinTemplate,
|
||||||
joinInfo.JoinType.ToString() + PubConst.Space,
|
joinInfo.JoinType.ToString() + UtilConstants.Space,
|
||||||
Builder.GetTranslationTableName(joinInfo.TableName) + PubConst.Space,
|
Builder.GetTranslationTableName(joinInfo.TableName) + UtilConstants.Space,
|
||||||
joinInfo.ShortName + PubConst.Space + joinInfo.TableWithString,
|
joinInfo.ShortName + UtilConstants.Space + joinInfo.TableWithString,
|
||||||
joinInfo.JoinWhere);
|
joinInfo.JoinWhere);
|
||||||
}
|
}
|
||||||
public virtual void Clear()
|
public virtual void Clear()
|
||||||
@ -392,7 +392,7 @@ namespace SqlSugar
|
|||||||
if (this.WhereInfos == null) return null;
|
if (this.WhereInfos == null) return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string.Join(PubConst.Space, this.WhereInfos);
|
return string.Join(UtilConstants.Space, this.WhereInfos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -403,7 +403,7 @@ namespace SqlSugar
|
|||||||
if (this.JoinQueryInfos.IsNullOrEmpty()) return null;
|
if (this.JoinQueryInfos.IsNullOrEmpty()) return null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return string.Join(PubConst.Space, this.JoinQueryInfos.Select(it => this.ToJoinString(it)));
|
return string.Join(UtilConstants.Space, this.JoinQueryInfos.Select(it => this.ToJoinString(it)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -412,18 +412,18 @@ namespace SqlSugar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var result = Builder.GetTranslationTableName(EntityName);
|
var result = Builder.GetTranslationTableName(EntityName);
|
||||||
result += PubConst.Space;
|
result += UtilConstants.Space;
|
||||||
if (this.TableWithString.IsValuable())
|
if (this.TableWithString.IsValuable())
|
||||||
{
|
{
|
||||||
result += TableWithString + PubConst.Space;
|
result += TableWithString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
if (this.TableShortName.IsValuable())
|
if (this.TableShortName.IsValuable())
|
||||||
{
|
{
|
||||||
result += (TableShortName + PubConst.Space);
|
result += (TableShortName + UtilConstants.Space);
|
||||||
}
|
}
|
||||||
if (!this.IsSingle())
|
if (!this.IsSingle())
|
||||||
{
|
{
|
||||||
result += GetJoinValueString + PubConst.Space;
|
result += GetJoinValueString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
if (this.EasyJoinInfos.IsValuable())
|
if (this.EasyJoinInfos.IsValuable())
|
||||||
{
|
{
|
||||||
@ -459,7 +459,7 @@ namespace SqlSugar
|
|||||||
if (this.GroupByValue == null) return null;
|
if (this.GroupByValue == null) return null;
|
||||||
if (this.GroupByValue.Last() != ' ' )
|
if (this.GroupByValue.Last() != ' ' )
|
||||||
{
|
{
|
||||||
return this.GroupByValue + PubConst.Space;
|
return this.GroupByValue + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
return this.GroupByValue;
|
return this.GroupByValue;
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
base._SqlQueryBuilder = PubMethod.IsNullReturnNew(base._SqlQueryBuilder);
|
base._SqlQueryBuilder = UtilMethods.IsNullReturnNew(base._SqlQueryBuilder);
|
||||||
return base._SqlQueryBuilder;
|
return base._SqlQueryBuilder;
|
||||||
}
|
}
|
||||||
set { base._SqlQueryBuilder = value; }
|
set { base._SqlQueryBuilder = value; }
|
||||||
@ -69,7 +69,15 @@ namespace SqlSugar
|
|||||||
public virtual string GetNoTranslationColumnName(string name)
|
public virtual string GetNoTranslationColumnName(string name)
|
||||||
{
|
{
|
||||||
if (!name.Contains(SqlTranslationLeft)) return name;
|
if (!name.Contains(SqlTranslationLeft)) return name;
|
||||||
return name == null ? string.Empty : Regex.Match(name, @".*"+"\\"+SqlTranslationLeft+"(.*?)"+"\\"+SqlTranslationRight+"").Groups[1].Value;
|
return name == null ? string.Empty : Regex.Match(name, @".*" + "\\" + SqlTranslationLeft + "(.*?)" + "\\" + SqlTranslationRight + "").Groups[1].Value;
|
||||||
|
}
|
||||||
|
public virtual string GetPackTable(string sql, string shortName)
|
||||||
|
{
|
||||||
|
return UtilMethods.GetPackTable(sql,shortName);
|
||||||
|
}
|
||||||
|
public virtual void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
|
||||||
|
{
|
||||||
|
UtilMethods.RepairReplicationParameters(ref appendSql,parameters,addIndex);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_Sql = PubMethod.IsNullReturnNew(_Sql);
|
_Sql = UtilMethods.IsNullReturnNew(_Sql);
|
||||||
return _Sql;
|
return _Sql;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
@ -60,7 +60,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
_Parameters = PubMethod.IsNullReturnNew(_Parameters);
|
_Parameters = UtilMethods.IsNullReturnNew(_Parameters);
|
||||||
return _Parameters;
|
return _Parameters;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
|
@ -92,10 +92,10 @@ namespace SqlSugar
|
|||||||
get
|
get
|
||||||
{
|
{
|
||||||
var result = Builder.GetTranslationTableName(TableName);
|
var result = Builder.GetTranslationTableName(TableName);
|
||||||
result += PubConst.Space;
|
result += UtilConstants.Space;
|
||||||
if (this.TableWithString.IsValuable())
|
if (this.TableWithString.IsValuable())
|
||||||
{
|
{
|
||||||
result += TableWithString + PubConst.Space;
|
result += TableWithString + UtilConstants.Space;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -250,7 +250,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type = value.GetType();
|
var type = value.GetType();
|
||||||
if (type == PubConst.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < Convert.ToDateTime("1900-1-1"))
|
||||||
@ -263,11 +263,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Convert.ToInt64(value);
|
return Convert.ToInt64(value);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
return value.ObjToBool() ? "1" : "0";
|
return value.ObjToBool() ? "1" : "0";
|
||||||
}
|
}
|
||||||
else if (type == PubConst.StringType || type == PubConst.ObjType)
|
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
return "N'" + value.ToString().ToSqlFilter() + "'";
|
return "N'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
@ -179,7 +179,7 @@ namespace SqlSugar
|
|||||||
Value = column.PropertyInfo.GetValue(item, null),
|
Value = column.PropertyInfo.GetValue(item, null),
|
||||||
DbColumnName = GetDbColumnName(column.PropertyName),
|
DbColumnName = GetDbColumnName(column.PropertyName),
|
||||||
PropertyName = column.PropertyName,
|
PropertyName = column.PropertyName,
|
||||||
PropertyType = PubMethod.GetUnderType(column.PropertyInfo),
|
PropertyType = UtilMethods.GetUnderType(column.PropertyInfo),
|
||||||
TableId = i
|
TableId = i
|
||||||
};
|
};
|
||||||
if (columnInfo.PropertyType.IsEnum())
|
if (columnInfo.PropertyType.IsEnum())
|
||||||
|
@ -19,5 +19,7 @@ namespace SqlSugar
|
|||||||
public bool IsIdentity { get; set; }
|
public bool IsIdentity { get; set; }
|
||||||
public bool IsPrimarykey { get; set; }
|
public bool IsPrimarykey { get; set; }
|
||||||
public object Value { get; set; }
|
public object Value { get; set; }
|
||||||
|
public int DecimalDigits { get; set; }
|
||||||
|
public int Scale { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,5 +10,6 @@ namespace SqlSugar
|
|||||||
public const string MySql = "MySql";
|
public const string MySql = "MySql";
|
||||||
public const string SqlServer = "SqlServer";
|
public const string SqlServer = "SqlServer";
|
||||||
public const string Sqlite = "Sqlite";
|
public const string Sqlite = "Sqlite";
|
||||||
|
public const string Oracle = "Oracle";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,5 +23,6 @@ namespace SqlSugar
|
|||||||
public string DbTableName { get; set; }
|
public string DbTableName { get; set; }
|
||||||
public bool IsIgnore { get; set; }
|
public bool IsIgnore { get; set; }
|
||||||
public string DataType { get; set; }
|
public string DataType { get; set; }
|
||||||
|
public int DecimalDigits { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,6 +86,12 @@ namespace SqlSugar
|
|||||||
get { return _ColumnDataType; }
|
get { return _ColumnDataType; }
|
||||||
set { _ColumnDataType = value; }
|
set { _ColumnDataType = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int _DecimalDigits;
|
||||||
|
public int DecimalDigits {
|
||||||
|
get { return _DecimalDigits; }
|
||||||
|
set { _DecimalDigits = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,4 @@ namespace SqlSugar
|
|||||||
Left = 1,
|
Left = 1,
|
||||||
Right = 2
|
Right = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
internal static partial class ErrorMessage
|
||||||
|
{
|
||||||
|
internal static string OperatorError
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ErrorMessage.GetThrowMessage("Lambda parsing error: {0} does not support the operator to find!","拉姆达解析出错:不支持{0}此种运算符查找!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal static string ExpFileldError
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ErrorMessage.GetThrowMessage("Expression format error, correct format: it=>it.fieldName","表达示格式错误,正确格式: it=>it.fieldName");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string MethodError
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ErrorMessage.GetThrowMessage("Expression parsing does not support the current function {0}. There are many functions available in the SqlFunc class, for example, it=>SqlFunc.HasValue(it.Id)", "拉姆达解析不支持当前函数{0},SqlFunc这个类里面有大量函数可用,也许有你想要的,例如: it=>SqlFunc.HasValue(it.Id)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -18,13 +18,5 @@ namespace SqlSugar
|
|||||||
public const string Const = "Const";
|
public const string Const = "Const";
|
||||||
public readonly static Type MemberExpressionType = typeof(MemberExpression);
|
public readonly static Type MemberExpressionType = typeof(MemberExpression);
|
||||||
public readonly static Type ConstantExpressionType = typeof(ConstantExpression);
|
public readonly static Type ConstantExpressionType = typeof(ConstantExpression);
|
||||||
public readonly static Type StringType = typeof(string);
|
|
||||||
|
|
||||||
internal static string GetThrowMessage(string enMessage, string cnMessage, params string[] args)
|
|
||||||
{
|
|
||||||
List<string> formatArgs = new List<string>() { enMessage, cnMessage };
|
|
||||||
formatArgs.AddRange(args);
|
|
||||||
return string.Format("\r\n English Message : {0}\r\n Chinese Message : {1}", formatArgs.ToArray());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
namespace SqlSugar
|
|
||||||
{
|
|
||||||
internal class ExpressionErrorMessage
|
|
||||||
{
|
|
||||||
internal static string OperatorError
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return ExpressionConst.GetThrowMessage("Lambda parsing error: {0} does not support the operator to find!","拉姆达解析出错:不支持{0}此种运算符查找!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
internal static string ExpFileldError
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return ExpressionConst.GetThrowMessage("Expression format error, correct format: it=>it.fieldName","表达示格式错误,正确格式: it=>it.fieldName");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static string MethodError
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return ExpressionConst.GetThrowMessage("Expression parsing does not support the current function {0}. There are many functions available in the SqlFunc class, for example, it=>SqlFunc.HasValue(it.Id)", "拉姆达解析不支持当前函数{0},SqlFunc这个类里面有大量函数可用,也许有你想要的,例如: it=>SqlFunc.HasValue(it.Id)");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -42,7 +42,7 @@ namespace SqlSugar
|
|||||||
case ExpressionType.MultiplyChecked:
|
case ExpressionType.MultiplyChecked:
|
||||||
return "*";
|
return "*";
|
||||||
default:
|
default:
|
||||||
Check.ThrowNotSupportedException(string.Format(ExpressionErrorMessage.OperatorError, expressiontype.ToString()));
|
Check.ThrowNotSupportedException(string.Format(ErrorMessage.OperatorError, expressiontype.ToString()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ namespace SqlSugar
|
|||||||
FieldInfo field = (FieldInfo)memberExpr.Member;
|
FieldInfo field = (FieldInfo)memberExpr.Member;
|
||||||
Check.Exception(field.IsPrivate, string.Format(" Field \"{0}\" can't be private ", field.Name));
|
Check.Exception(field.IsPrivate, string.Format(" Field \"{0}\" can't be private ", field.Name));
|
||||||
reval = field.GetValue(memberExpr.Member);
|
reval = field.GetValue(memberExpr.Member);
|
||||||
if (reval != null && reval.GetType().IsClass() && reval.GetType() != ExpressionConst.StringType)
|
if (reval != null && reval.GetType().IsClass() && reval.GetType() != UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
var fieldName = memberExpr.Member.Name;
|
var fieldName = memberExpr.Member.Name;
|
||||||
var proInfo = reval.GetType().GetProperty(fieldName);
|
var proInfo = reval.GetType().GetProperty(fieldName);
|
||||||
@ -190,7 +190,7 @@ namespace SqlSugar
|
|||||||
object reval = null;
|
object reval = null;
|
||||||
PropertyInfo pro = (PropertyInfo)memberExpr.Member;
|
PropertyInfo pro = (PropertyInfo)memberExpr.Member;
|
||||||
reval = pro.GetValue(memberExpr.Member, null);
|
reval = pro.GetValue(memberExpr.Member, null);
|
||||||
if (reval != null && reval.GetType().IsClass() && reval.GetType() != ExpressionConst.StringType)
|
if (reval != null && reval.GetType().IsClass() && reval.GetType() != UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
var fieldName = memberExpr.Member.Name;
|
var fieldName = memberExpr.Member.Name;
|
||||||
var proInfo = reval.GetType().GetProperty(fieldName);
|
var proInfo = reval.GetType().GetProperty(fieldName);
|
||||||
@ -214,7 +214,7 @@ namespace SqlSugar
|
|||||||
public static object DynamicInvoke(Expression expression,MemberExpression memberExpression=null)
|
public static object DynamicInvoke(Expression expression,MemberExpression memberExpression=null)
|
||||||
{
|
{
|
||||||
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
object value = Expression.Lambda(expression).Compile().DynamicInvoke();
|
||||||
if (value != null && value.GetType().IsClass() && value.GetType() != ExpressionConst.StringType&& memberExpression!=null)
|
if (value != null && value.GetType().IsClass() && value.GetType() != UtilConstants.StringType&& memberExpression!=null)
|
||||||
{
|
{
|
||||||
value = Expression.Lambda(memberExpression).Compile().DynamicInvoke();
|
value = Expression.Lambda(memberExpression).Compile().DynamicInvoke();
|
||||||
}
|
}
|
||||||
@ -233,7 +233,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public static bool IsEntity(Type type)
|
public static bool IsEntity(Type type)
|
||||||
{
|
{
|
||||||
return type.IsClass() && type != ExpressionConst.StringType;
|
return type.IsClass() && type != UtilConstants.StringType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsValueType(Type type)
|
public static bool IsValueType(Type type)
|
||||||
|
@ -27,47 +27,47 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private void SettingDataType(Type type)
|
private void SettingDataType(Type type)
|
||||||
{
|
{
|
||||||
if (type == PubConst.ByteArrayType)
|
if (type == UtilConstants.ByteArrayType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Binary;
|
this.DbType = System.Data.DbType.Binary;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.GuidType)
|
else if (type == UtilConstants.GuidType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Guid;
|
this.DbType = System.Data.DbType.Guid;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.IntType)
|
else if (type == UtilConstants.IntType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Int32;
|
this.DbType = System.Data.DbType.Int32;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.ShortType)
|
else if (type == UtilConstants.ShortType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Int16;
|
this.DbType = System.Data.DbType.Int16;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.LongType)
|
else if (type == UtilConstants.LongType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Int64;
|
this.DbType = System.Data.DbType.Int64;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DateType)
|
else if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.DateTime;
|
this.DbType = System.Data.DbType.DateTime;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DobType)
|
else if (type == UtilConstants.DobType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Double;
|
this.DbType = System.Data.DbType.Double;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.DecType)
|
else if (type == UtilConstants.DecType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Decimal;
|
this.DbType = System.Data.DbType.Decimal;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.ByteType)
|
else if (type == UtilConstants.ByteType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Byte;
|
this.DbType = System.Data.DbType.Byte;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.FloatType)
|
else if (type == UtilConstants.FloatType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Single;
|
this.DbType = System.Data.DbType.Single;
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
this.DbType = System.Data.DbType.Boolean;
|
this.DbType = System.Data.DbType.Boolean;
|
||||||
}
|
}
|
||||||
@ -109,7 +109,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (_Size == 0 && Value != null)
|
if (_Size == 0 && Value != null)
|
||||||
{
|
{
|
||||||
var isByteArray = Value.GetType() == PubConst.ByteArrayType;
|
var isByteArray = Value.GetType() == UtilConstants.ByteArrayType;
|
||||||
if (isByteArray)
|
if (isByteArray)
|
||||||
_Size = -1;
|
_Size = -1;
|
||||||
else
|
else
|
||||||
|
@ -96,6 +96,8 @@ namespace SqlSugar
|
|||||||
return "@";
|
return "@";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public virtual string SqlTranslationLeft { get { return "["; } }
|
||||||
|
public virtual string SqlTranslationRight { get { return "]"; } }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region public functions
|
#region public functions
|
||||||
@ -103,34 +105,30 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
||||||
if (IsTranslationText(entityName)) return entityName;
|
if (IsTranslationText(entityName)) return entityName;
|
||||||
if (isMapping && this.MappingTables.IsValuable())
|
isMapping = isMapping && this.MappingTables.IsValuable();
|
||||||
|
var isComplex = entityName.Contains(".");
|
||||||
|
if (isMapping && isComplex)
|
||||||
{
|
{
|
||||||
if (entityName.Contains("."))
|
var columnInfo = entityName.Split('.');
|
||||||
|
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
if (mappingInfo != null)
|
||||||
{
|
{
|
||||||
var columnInfo = entityName.Split('.');
|
columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
if (mappingInfo != null)
|
|
||||||
{
|
|
||||||
columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
|
|
||||||
}
|
|
||||||
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
return "[" + (mappingInfo == null ? entityName : mappingInfo.EntityName) + "]";
|
|
||||||
}
|
}
|
||||||
|
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
||||||
|
}
|
||||||
|
else if (isMapping)
|
||||||
|
{
|
||||||
|
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
||||||
|
return SqlTranslationLeft + (mappingInfo == null ? entityName : mappingInfo.EntityName) + SqlTranslationRight;
|
||||||
|
}
|
||||||
|
else if (isComplex)
|
||||||
|
{
|
||||||
|
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (entityName.Contains("."))
|
return GetTranslationText(entityName);
|
||||||
{
|
|
||||||
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return GetTranslationText(entityName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual string GetTranslationColumnName(string columnName)
|
public virtual string GetTranslationColumnName(string columnName)
|
||||||
@ -164,11 +162,11 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual bool IsTranslationText(string name)
|
public virtual bool IsTranslationText(string name)
|
||||||
{
|
{
|
||||||
return name.Contains("[") && name.Contains("]");
|
return name.Contains(SqlTranslationLeft) && name.Contains(SqlTranslationRight);
|
||||||
}
|
}
|
||||||
public virtual string GetTranslationText(string name)
|
public virtual string GetTranslationText(string name)
|
||||||
{
|
{
|
||||||
return "[" + name + "]";
|
return SqlTranslationLeft + name + SqlTranslationRight;
|
||||||
}
|
}
|
||||||
public virtual void Resolve(Expression expression, ResolveExpressType resolveType)
|
public virtual void Resolve(Expression expression, ResolveExpressType resolveType)
|
||||||
{
|
{
|
||||||
@ -179,7 +177,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public virtual string GetAsString(string asName, string fieldValue)
|
public virtual string GetAsString(string asName, string fieldValue)
|
||||||
{
|
{
|
||||||
if (fieldValue.Contains(".*")|| fieldValue=="*") return fieldValue;
|
if (fieldValue.Contains(".*") || fieldValue == "*") return fieldValue;
|
||||||
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldValue), "AS", GetTranslationColumnName(asName));
|
return string.Format(" {0} {1} {2} ", GetTranslationColumnName(fieldValue), "AS", GetTranslationColumnName(asName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var parentIsBinary = parameter.BaseParameter.CurrentExpression is BinaryExpression;
|
var parentIsBinary = parameter.BaseParameter.CurrentExpression is BinaryExpression;
|
||||||
var parentIsRoot = parameter.BaseParameter.CurrentExpression is LambdaExpression;
|
var parentIsRoot = parameter.BaseParameter.CurrentExpression is LambdaExpression;
|
||||||
var isBool = value != null && value.GetType() == PubConst.BoolType;
|
var isBool = value != null && value.GetType() == UtilConstants.BoolType;
|
||||||
if (parentIsRoot && isBool)
|
if (parentIsRoot && isBool)
|
||||||
{
|
{
|
||||||
this.Context.Result.Append(value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False());
|
this.Context.Result.Append(value.ObjToBool() ? this.Context.DbMehtods.True() : this.Context.DbMehtods.False());
|
||||||
|
@ -15,10 +15,10 @@ namespace SqlSugar
|
|||||||
var isSetTempData = baseParameter.CommonTempData.IsValuable() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);
|
var isSetTempData = baseParameter.CommonTempData.IsValuable() && baseParameter.CommonTempData.Equals(CommonTempDataType.Result);
|
||||||
var expression = base.Expression as MemberExpression;
|
var expression = base.Expression as MemberExpression;
|
||||||
var isValue = expression.Member.Name == "Value" && expression.Member.DeclaringType.Name == "Nullable`1";
|
var isValue = expression.Member.Name == "Value" && expression.Member.DeclaringType.Name == "Nullable`1";
|
||||||
var isBool = expression.Type == PubConst.BoolType;
|
var isBool = expression.Type == UtilConstants.BoolType;
|
||||||
var isValueBool = isValue && isBool && parameter.BaseExpression == null;
|
var isValueBool = isValue && isBool && parameter.BaseExpression == null;
|
||||||
var isLength = expression.Member.Name == "Length" && (expression.Expression as MemberExpression).Type == PubConst.StringType;
|
var isLength = expression.Member.Name == "Length" && (expression.Expression as MemberExpression).Type == UtilConstants.StringType;
|
||||||
var isDateValue = expression.Member.Name.IsIn(Enum.GetNames(typeof(DateType))) && (expression.Expression as MemberExpression).Type == PubConst.DateType;
|
var isDateValue = expression.Member.Name.IsIn(Enum.GetNames(typeof(DateType))) && (expression.Expression as MemberExpression).Type == UtilConstants.DateType;
|
||||||
var isLogicOperator = ExpressionTool.IsLogicOperator(baseParameter.OperatorValue) || baseParameter.OperatorValue.IsNullOrEmpty();
|
var isLogicOperator = ExpressionTool.IsLogicOperator(baseParameter.OperatorValue) || baseParameter.OperatorValue.IsNullOrEmpty();
|
||||||
var isHasValue = isLogicOperator && expression.Member.Name == "HasValue" && expression.Expression != null && expression.NodeType == ExpressionType.MemberAccess;
|
var isHasValue = isLogicOperator && expression.Member.Name == "HasValue" && expression.Expression != null && expression.NodeType == ExpressionType.MemberAccess;
|
||||||
if (isLength)
|
if (isLength)
|
||||||
@ -144,7 +144,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
fieldName = GetName(parameter, expression, isLeft, isSingle);
|
fieldName = GetName(parameter, expression, isLeft, isSingle);
|
||||||
}
|
}
|
||||||
if (expression.Type == PubConst.BoolType && baseParameter.OperatorValue.IsNullOrEmpty())
|
if (expression.Type == UtilConstants.BoolType && baseParameter.OperatorValue.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
fieldName = "( " + fieldName + "=1 )";
|
fieldName = "( " + fieldName + "=1 )";
|
||||||
}
|
}
|
||||||
|
@ -161,10 +161,10 @@ namespace SqlSugar
|
|||||||
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
|
var isBinaryExpression = item is BinaryExpression || item is MethodCallExpression;
|
||||||
var isConst = item is ConstantExpression;
|
var isConst = item is ConstantExpression;
|
||||||
var isIIF= name == "IIF";
|
var isIIF= name == "IIF";
|
||||||
var isIFFBoolMember = isIIF && (item is MemberExpression) && (item as MemberExpression).Type == PubConst.BoolType;
|
var isIFFBoolMember = isIIF && (item is MemberExpression) && (item as MemberExpression).Type == UtilConstants.BoolType;
|
||||||
var isIFFUnary = isIIF && (item is UnaryExpression) && (item as UnaryExpression).Operand.Type == PubConst.BoolType;
|
var isIFFUnary = isIIF && (item is UnaryExpression) && (item as UnaryExpression).Operand.Type == UtilConstants.BoolType;
|
||||||
var isIFFBoolBinary = isIIF && (item is BinaryExpression) && (item as BinaryExpression).Type == PubConst.BoolType;
|
var isIFFBoolBinary = isIIF && (item is BinaryExpression) && (item as BinaryExpression).Type == UtilConstants.BoolType;
|
||||||
var isIFFBoolMethod = isIIF && (item is MethodCallExpression) && (item as MethodCallExpression).Type == PubConst.BoolType;
|
var isIFFBoolMethod = isIIF && (item is MethodCallExpression) && (item as MethodCallExpression).Type == UtilConstants.BoolType;
|
||||||
var isFirst = item == args.First();
|
var isFirst = item == args.First();
|
||||||
if (isFirst && isIIF && isConst)
|
if (isFirst && isIIF && isConst)
|
||||||
{
|
{
|
||||||
@ -427,7 +427,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private void CheckMethod(MethodCallExpression expression)
|
private void CheckMethod(MethodCallExpression expression)
|
||||||
{
|
{
|
||||||
Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName, string.Format(ExpressionErrorMessage.MethodError, expression.Method.Name));
|
Check.Exception(expression.Method.ReflectedType().FullName != ExpressionConst.SqlFuncFullName, string.Format(ErrorMessage.MethodError, expression.Method.Name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,11 @@ namespace SqlSugar
|
|||||||
Check.ThrowNotSupportedException(expression.ToString());
|
Check.ThrowNotSupportedException(expression.ToString());
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.SelectSingle:
|
case ResolveExpressType.SelectSingle:
|
||||||
Check.Exception(expression.Type == PubConst.DateType, "ThrowNotSupportedException {0} ",expression.ToString());
|
Check.Exception(expression.Type == UtilConstants.DateType, "ThrowNotSupportedException {0} ",expression.ToString());
|
||||||
Select(expression, parameter, true);
|
Select(expression, parameter, true);
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.SelectMultiple:
|
case ResolveExpressType.SelectMultiple:
|
||||||
Check.Exception(expression.Type == PubConst.DateType, "ThrowNotSupportedException {0} ", expression.ToString());
|
Check.Exception(expression.Type == UtilConstants.DateType, "ThrowNotSupportedException {0} ", expression.ToString());
|
||||||
Select(expression, parameter, false);
|
Select(expression, parameter, false);
|
||||||
break;
|
break;
|
||||||
case ResolveExpressType.FieldSingle:
|
case ResolveExpressType.FieldSingle:
|
||||||
|
@ -92,7 +92,7 @@ namespace SqlSugar
|
|||||||
parameter.CommonTempData = null;
|
parameter.CommonTempData = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (memberExpression.Type == PubConst.BoolType && isLogicOperator)
|
else if (memberExpression.Type == UtilConstants.BoolType && isLogicOperator)
|
||||||
{
|
{
|
||||||
Append(parameter, nodeType);
|
Append(parameter, nodeType);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class InstanceFactory
|
public class InstanceFactory
|
||||||
{
|
{
|
||||||
static Assembly assembly = ReflectionCore.Load(PubConst.AssemblyName);
|
static Assembly assembly = Assembly.Load(UtilConstants.AssemblyName);
|
||||||
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
static Dictionary<string, Type> typeCache = new Dictionary<string, Type>();
|
||||||
|
|
||||||
#region Queryable
|
#region Queryable
|
||||||
@ -202,7 +202,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
private static string GetClassName(string type, string name)
|
private static string GetClassName(string type, string name)
|
||||||
{
|
{
|
||||||
return PubConst.AssemblyName + "." + type + name;
|
return UtilConstants.AssemblyName + "." + type + name;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region CreateInstance
|
#region CreateInstance
|
@ -26,7 +26,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dic.Add(reader.GetName(i), reader.GetValue(i));
|
var addItem = reader.GetValue(i);
|
||||||
|
if (addItem == DBNull.Value)
|
||||||
|
addItem = null;
|
||||||
|
dic.Add(reader.GetName(i), addItem);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -66,7 +69,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
result.Add(reader.GetName(i), reader.GetValue(i));
|
var addItem = reader.GetValue(i);
|
||||||
|
if (addItem == DBNull.Value)
|
||||||
|
addItem = null;
|
||||||
|
result.Add(reader.GetName(i), addItem);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -108,29 +114,30 @@ namespace SqlSugar
|
|||||||
var addValue = readerValues[name];
|
var addValue = readerValues[name];
|
||||||
if (addValue == DBNull.Value)
|
if (addValue == DBNull.Value)
|
||||||
{
|
{
|
||||||
if (item.PropertyType.IsIn(PubConst.IntType, PubConst.DecType, PubConst.DobType, PubConst.ByteType))
|
if (item.PropertyType.IsIn(UtilConstants.IntType, UtilConstants.DecType, UtilConstants.DobType, UtilConstants.ByteType))
|
||||||
{
|
{
|
||||||
addValue = 0;
|
addValue = 0;
|
||||||
}
|
}
|
||||||
else if (item.PropertyType == PubConst.GuidType)
|
else if (item.PropertyType == UtilConstants.GuidType)
|
||||||
{
|
{
|
||||||
addValue = Guid.Empty;
|
addValue = Guid.Empty;
|
||||||
}
|
}
|
||||||
else if (item.PropertyType == PubConst.DateType)
|
else if (item.PropertyType == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
addValue = DateTime.MinValue;
|
addValue = DateTime.MinValue;
|
||||||
}
|
}
|
||||||
else if (item.PropertyType == PubConst.StringType)
|
else if (item.PropertyType == UtilConstants.StringType)
|
||||||
{
|
{
|
||||||
addValue = null;
|
addValue = null;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
addValue = null;
|
addValue = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (item.PropertyType == PubConst.IntType)
|
if (item.PropertyType == UtilConstants.IntType)
|
||||||
{
|
{
|
||||||
addValue = Convert.ToInt32(addValue);
|
addValue = Convert.ToInt32(addValue);
|
||||||
}
|
}
|
||||||
@ -165,10 +172,10 @@ namespace SqlSugar
|
|||||||
var key = typeName + "." + name;
|
var key = typeName + "." + name;
|
||||||
if (readerValues.ContainsKey(key))
|
if (readerValues.ContainsKey(key))
|
||||||
{
|
{
|
||||||
var addValue = readerValues[key];
|
var addItem = readerValues[key];
|
||||||
if (addValue == DBNull.Value)
|
if (addItem == DBNull.Value)
|
||||||
addValue = null;
|
addItem = null;
|
||||||
result.Add(name,addValue );
|
result.Add(name, addItem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,10 +201,6 @@ namespace SqlSugar
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T DeserializeObject<T>(string value)
|
public T DeserializeObject<T>(string value)
|
||||||
{
|
{
|
||||||
if (value.IsValuable())
|
|
||||||
{
|
|
||||||
value = value.Replace(":{}", ":null");
|
|
||||||
}
|
|
||||||
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
var jSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
|
||||||
return JsonConvert.DeserializeObject<T>(value,jSetting);
|
return JsonConvert.DeserializeObject<T>(value,jSetting);
|
||||||
}
|
}
|
||||||
@ -231,10 +234,10 @@ namespace SqlSugar
|
|||||||
childRow = new Dictionary<string, object>();
|
childRow = new Dictionary<string, object>();
|
||||||
foreach (DataColumn col in table.Columns)
|
foreach (DataColumn col in table.Columns)
|
||||||
{
|
{
|
||||||
var addValue = row[col];
|
var addItem = row[col];
|
||||||
if (addValue == DBNull.Value)
|
if (addItem == DBNull.Value)
|
||||||
addValue = null;
|
addItem = null;
|
||||||
childRow.Add(col.ColumnName, addValue);
|
childRow.Add(col.ColumnName, addItem);
|
||||||
}
|
}
|
||||||
deserializeObject.Add(childRow);
|
deserializeObject.Add(childRow);
|
||||||
}
|
}
|
@ -277,7 +277,7 @@ namespace SqlSugar
|
|||||||
var index = 1;
|
var index = 1;
|
||||||
foreach (var item in entityTypeArray)
|
foreach (var item in entityTypeArray)
|
||||||
{
|
{
|
||||||
result.Add(PubConst.Space +lambdaParameters[index].Name, item.Name);
|
result.Add(UtilConstants.Space +lambdaParameters[index].Name, item.Name);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
@ -62,7 +62,7 @@ namespace SqlSugar
|
|||||||
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
|
ISugarQueryable<TResult> Select<TResult>(Expression<Func<T, TResult>> expression);
|
||||||
ISugarQueryable<TResult> Select<TResult>(string select);
|
ISugarQueryable<TResult> Select<TResult>(string select);
|
||||||
ISugarQueryable<T> Select(string select);
|
ISugarQueryable<T> Select(string select);
|
||||||
|
ISugarQueryable<T> MergeTable();
|
||||||
|
|
||||||
int Count();
|
int Count();
|
||||||
TResult Max<TResult>(string maxField);
|
TResult Max<TResult>(string maxField);
|
||||||
@ -125,6 +125,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T,T2, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T,T2, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T,T2, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T,T2, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T,T2> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T,T2> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T,T2> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -164,6 +170,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2,T3, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2,T3, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2,T3, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2,T3, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2,T3> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2,T3> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2,T3> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -208,6 +220,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3,T4,TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3,T4,TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3,T4,TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3,T4,TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3,T4> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3,T4> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3,T4> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -258,6 +276,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4,T5,TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4,T5,TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4,T5,TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4,T5,TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -312,6 +336,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5,T6,TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5,T6,TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5,T6,TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5,T6,TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5,T6> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5,T6> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4,T5,T6> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -371,6 +401,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7,TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7,TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7,TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6,T7,TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6,T7> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -435,6 +471,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7,T8, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7,T8> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
#region 9-12
|
#region 9-12
|
||||||
@ -506,6 +548,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -580,6 +628,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10,T11> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10,T11> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -659,6 +713,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10,T11,T12> : ISugarQueryable<T>
|
public partial interface ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9,T10,T11,T12> : ISugarQueryable<T>
|
||||||
{
|
{
|
||||||
@ -743,6 +803,12 @@ namespace SqlSugar
|
|||||||
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression);
|
TResult Sum<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression);
|
||||||
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression);
|
TResult Avg<TResult>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12, TResult>> expression);
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region In
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> In<FieldType>(Expression<Func<T, object>> expression, params FieldType[] inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> In<FieldType>(Expression<Func<T, object>> expression, List<FieldType> inValues);
|
||||||
|
new ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> In<FieldType>(Expression<Func<T, object>> expression, ISugarQueryable<FieldType> childQueryExpression);
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ namespace SqlSugar
|
|||||||
string GetTranslationColumnName(string entityName, string propertyName);
|
string GetTranslationColumnName(string entityName, string propertyName);
|
||||||
string GetTranslationColumnName(string propertyName);
|
string GetTranslationColumnName(string propertyName);
|
||||||
string GetNoTranslationColumnName(string name);
|
string GetNoTranslationColumnName(string name);
|
||||||
|
string GetPackTable(string sql,string shortName);
|
||||||
|
void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,7 @@
|
|||||||
{
|
{
|
||||||
void Fill(DataSet ds);
|
void Fill(DataSet ds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
namespace System.Data.Sqlite {
|
||||||
|
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var result = new DbColumnInfo()
|
var result = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
DataType = this.Context.Ado.DbBind.GetDbTypeName(PubMethod.GetUnderType(item.PropertyInfo).Name),
|
DataType = this.Context.Ado.DbBind.GetDbTypeName(UtilMethods.GetUnderType(item.PropertyInfo).Name),
|
||||||
TableId = entityInfo.Columns.IndexOf(item),
|
TableId = entityInfo.Columns.IndexOf(item),
|
||||||
DbColumnName = item.DbColumnName.IsValuable() ? item.DbColumnName : item.PropertyName,
|
DbColumnName = item.DbColumnName.IsValuable() ? item.DbColumnName : item.PropertyName,
|
||||||
IsPrimarykey = item.IsPrimarykey,
|
IsPrimarykey = item.IsPrimarykey,
|
||||||
|
@ -8,7 +8,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public override string GetDbTypeName(string csharpTypeName)
|
public override string GetDbTypeName(string csharpTypeName)
|
||||||
{
|
{
|
||||||
if (csharpTypeName == PubConst.ByteArrayType.Name)
|
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
|
||||||
{
|
{
|
||||||
return "blob";
|
return "blob";
|
||||||
}
|
}
|
||||||
|
@ -9,48 +9,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
base.DbMehtods = new MySqlMethod();
|
base.DbMehtods = new MySqlMethod();
|
||||||
}
|
}
|
||||||
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
public override string SqlTranslationLeft { get { return "`"; } }
|
||||||
{
|
public override string SqlTranslationRight { get { return "`"; } }
|
||||||
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
|
||||||
if (IsTranslationText(entityName)) return entityName;
|
|
||||||
if (isMapping && this.MappingTables.IsValuable())
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
var columnInfo = entityName.Split('.');
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
if (mappingInfo != null)
|
|
||||||
{
|
|
||||||
columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
|
|
||||||
}
|
|
||||||
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
return "`" + (mappingInfo == null ? entityName : mappingInfo.EntityName) + "`";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return GetTranslationText(entityName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override bool IsTranslationText(string name)
|
|
||||||
{
|
|
||||||
return name.Contains("`") && name.Contains("`");
|
|
||||||
}
|
|
||||||
public override string GetTranslationText(string name)
|
|
||||||
{
|
|
||||||
return "`" + name + "`";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public class MySqlMethod : DefaultDbMethod, IDbMethods
|
public class MySqlMethod : DefaultDbMethod, IDbMethods
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "SELECT {0}{{$:OrderByString:$}} FROM {1}{2}{3}{4}";
|
return "SELECT {0}{"+UtilConstants.OrderReplace+"} FROM {1}{2}{3}{4}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
var result = new DbColumnInfo()
|
var result = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
DataType = this.Context.Ado.DbBind.GetDbTypeName(PubMethod.GetUnderType(item.PropertyInfo).Name),
|
DataType = this.Context.Ado.DbBind.GetDbTypeName(UtilMethods.GetUnderType(item.PropertyInfo).Name),
|
||||||
TableId = entityInfo.Columns.IndexOf(item),
|
TableId = entityInfo.Columns.IndexOf(item),
|
||||||
DbColumnName = item.DbColumnName.IsValuable() ? item.DbColumnName : item.PropertyName,
|
DbColumnName = item.DbColumnName.IsValuable() ? item.DbColumnName : item.PropertyName,
|
||||||
IsPrimarykey = item.IsPrimarykey,
|
IsPrimarykey = item.IsPrimarykey,
|
||||||
|
@ -8,7 +8,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public override string GetDbTypeName(string csharpTypeName)
|
public override string GetDbTypeName(string csharpTypeName)
|
||||||
{
|
{
|
||||||
if (csharpTypeName == PubConst.ByteArrayType.Name)
|
if (csharpTypeName == UtilConstants.ByteArrayType.Name)
|
||||||
{
|
{
|
||||||
return "blob";
|
return "blob";
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.Common;
|
using System.Data.Common;
|
||||||
|
using System.Data.Sqlite;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@ -22,14 +23,14 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return @"select Name from sqlite_master where type='table' and name<>'sqlite_sequence' order by name;";
|
return @"select Name from Sqlite_master where type='table' and name<>'Sqlite_sequence' order by name;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
protected override string GetViewInfoListSql
|
protected override string GetViewInfoListSql
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return @"select Name from sqlite_master where type='view' order by name;";
|
return @"select Name from Sqlite_master where type='view' order by name;";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -127,7 +128,7 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return "select Name from sqlite_master limit 0,1";
|
return "select Name from Sqlite_master limit 0,1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -175,32 +176,27 @@ namespace SqlSugar
|
|||||||
|
|
||||||
}, (cm, key) =>
|
}, (cm, key) =>
|
||||||
{
|
{
|
||||||
string sql = "PRAGMA table_info(" + tableName + ")";
|
string sql = "select * from " + tableName + " limit 0,1";
|
||||||
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
var oldIsEnableLog = this.Context.Ado.IsEnableLogEvent;
|
||||||
this.Context.Ado.IsEnableLogEvent = false;
|
this.Context.Ado.IsEnableLogEvent = false;
|
||||||
using (DbDataReader dataReader = (SqliteDataReader)this.Context.Ado.GetDataReader(sql))
|
using (DbDataReader reader = (SqliteDataReader)this.Context.Ado.GetDataReader(sql))
|
||||||
{
|
{
|
||||||
|
this.Context.Ado.IsEnableLogEvent = oldIsEnableLog;
|
||||||
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
List<DbColumnInfo> result = new List<DbColumnInfo>();
|
||||||
while (dataReader.Read())
|
var schemaTable = reader.GetSchemaTable();
|
||||||
|
foreach (DataRow row in schemaTable.Rows)
|
||||||
{
|
{
|
||||||
var type = dataReader.GetValue(2).ObjToString();
|
|
||||||
var length = 0;
|
|
||||||
if (type.Contains("("))
|
|
||||||
{
|
|
||||||
type = type.Split('(').First();
|
|
||||||
length = type.Split('(').Last().TrimEnd(')').ObjToInt();
|
|
||||||
}
|
|
||||||
DbColumnInfo column = new DbColumnInfo()
|
DbColumnInfo column = new DbColumnInfo()
|
||||||
{
|
{
|
||||||
TableName = tableName,
|
TableName = tableName,
|
||||||
DataType = type,
|
DataType = row["DataTypeName"].ToString().Trim(),
|
||||||
IsNullable = !dataReader.GetBoolean(3),
|
IsNullable = (bool)row["AllowDBNull"],
|
||||||
IsIdentity = dataReader.GetBoolean(3) && dataReader.GetBoolean(5).ObjToBool() && (type.IsIn("integer", "int", "int32", "int64", "long")),
|
IsIdentity = (bool)row["IsAutoIncrement"],
|
||||||
ColumnDescription = null,
|
ColumnDescription = null,
|
||||||
DbColumnName = dataReader.GetString(1),
|
DbColumnName = row["ColumnName"].ToString(),
|
||||||
DefaultValue = dataReader.GetValue(4).ObjToString(),
|
DefaultValue = row["defaultValue"].ToString(),
|
||||||
IsPrimarykey = dataReader.GetBoolean(5).ObjToBool(),
|
IsPrimarykey = (bool)row["IsKey"],
|
||||||
Length = length
|
Length = Convert.ToInt32(row["ColumnSize"])
|
||||||
};
|
};
|
||||||
result.Add(column);
|
result.Add(column);
|
||||||
}
|
}
|
||||||
|
@ -9,48 +9,8 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
base.DbMehtods = new SqliteMethod();
|
base.DbMehtods = new SqliteMethod();
|
||||||
}
|
}
|
||||||
public override string GetTranslationTableName(string entityName, bool isMapping = true)
|
public override string SqlTranslationLeft { get { return "`"; } }
|
||||||
{
|
public override string SqlTranslationRight { get { return "`"; } }
|
||||||
Check.ArgumentNullException(entityName, string.Format(ErrorMessage.ObjNotExist, "Table Name"));
|
|
||||||
if (IsTranslationText(entityName)) return entityName;
|
|
||||||
if (isMapping && this.MappingTables.IsValuable())
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
var columnInfo = entityName.Split('.');
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(columnInfo.Last(), StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
if (mappingInfo != null)
|
|
||||||
{
|
|
||||||
columnInfo[columnInfo.Length - 1] = mappingInfo.EntityName;
|
|
||||||
}
|
|
||||||
return string.Join(".", columnInfo.Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var mappingInfo = this.MappingTables.FirstOrDefault(it => it.EntityName.Equals(entityName, StringComparison.CurrentCultureIgnoreCase));
|
|
||||||
return "`" + (mappingInfo == null ? entityName : mappingInfo.EntityName) + "`";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (entityName.Contains("."))
|
|
||||||
{
|
|
||||||
return string.Join(".", entityName.Split('.').Select(it => GetTranslationText(it)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return GetTranslationText(entityName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public override bool IsTranslationText(string name)
|
|
||||||
{
|
|
||||||
return name.Contains("`") && name.Contains("`");
|
|
||||||
}
|
|
||||||
public override string GetTranslationText(string name)
|
|
||||||
{
|
|
||||||
return "`" + name + "`";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
public class SqliteMethod : DefaultDbMethod, IDbMethods
|
public class SqliteMethod : DefaultDbMethod, IDbMethods
|
||||||
{
|
{
|
||||||
|
@ -43,7 +43,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type = value.GetType();
|
var type = value.GetType();
|
||||||
if (type == PubConst.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < Convert.ToDateTime("1900-1-1"))
|
||||||
@ -56,11 +56,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Convert.ToInt64(value);
|
return Convert.ToInt64(value);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
return value.ObjToBool() ? "1" : "0";
|
return value.ObjToBool() ? "1" : "0";
|
||||||
}
|
}
|
||||||
else if (type == PubConst.StringType || type == PubConst.ObjType)
|
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
return "'" + value.ToString().ToSqlFilter() + "'";
|
return "'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ namespace SqlSugar
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var type = value.GetType();
|
var type = value.GetType();
|
||||||
if (type == PubConst.DateType)
|
if (type == UtilConstants.DateType)
|
||||||
{
|
{
|
||||||
var date = value.ObjToDate();
|
var date = value.ObjToDate();
|
||||||
if (date < Convert.ToDateTime("1900-1-1"))
|
if (date < Convert.ToDateTime("1900-1-1"))
|
||||||
@ -33,11 +33,11 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return Convert.ToInt64(value);
|
return Convert.ToInt64(value);
|
||||||
}
|
}
|
||||||
else if (type == PubConst.BoolType)
|
else if (type == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
return value.ObjToBool() ? "1" : "0";
|
return value.ObjToBool() ? "1" : "0";
|
||||||
}
|
}
|
||||||
else if (type == PubConst.StringType || type == PubConst.ObjType)
|
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||||
{
|
{
|
||||||
return "'" + value.ToString().ToSqlFilter() + "'";
|
return "'" + value.ToString().ToSqlFilter() + "'";
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
using System.Data.Sqlite;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -1,42 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Data;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace SqlSugar
|
|
||||||
{
|
|
||||||
public partial class SqliteProvider : AdoProvider
|
|
||||||
{
|
|
||||||
public override void ExecuteBefore(string sql, SugarParameter[] parameters)
|
|
||||||
{
|
|
||||||
if (sql.IsValuable() && parameters.IsValuable())
|
|
||||||
{
|
|
||||||
foreach (var parameter in parameters)
|
|
||||||
{
|
|
||||||
//Compatible with.NET CORE parameters case
|
|
||||||
var name = parameter.ParameterName;
|
|
||||||
if (!sql.Contains(name) && Regex.IsMatch(sql, "(" + name + "$)" + "|(" + name + @"[ ,\,])", RegexOptions.IgnoreCase)) {
|
|
||||||
parameter.ParameterName=Regex.Match(sql, "(" + name + "$)" + "|(" + name + @"[ ,\,])", RegexOptions.IgnoreCase).Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.IsEnableLogEvent)
|
|
||||||
{
|
|
||||||
Action<string, string> action = LogEventStarting;
|
|
||||||
if (action != null)
|
|
||||||
{
|
|
||||||
if (parameters == null || parameters.Length == 0)
|
|
||||||
{
|
|
||||||
action(sql, null);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
action(sql, this.Context.RewritableMethods.SerializeObject(parameters.Select(it => new { key = it.ParameterName, value = it.Value.ObjToString() })));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -31,6 +31,10 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
base.Context = this;
|
base.Context = this;
|
||||||
base.CurrentConnectionConfig = config;
|
base.CurrentConnectionConfig = config;
|
||||||
|
if (config.DbType == DbType.Oracle)
|
||||||
|
{
|
||||||
|
throw new Exception("Oracle developed 60%,to be continued ");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -261,37 +265,37 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
|
|
||||||
#region 9-12
|
#region 9-12
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8,T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8,T9, bool>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, bool>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8,T9>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8),typeof(T9) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8,T9>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9>(base.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9,T10, bool>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, bool>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9,T10>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9) ,typeof(T10)};
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9,T10>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10>(base.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11, bool>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, bool>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10,T11>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10),typeof(T11) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10,T11>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11>(base.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
return queryable;
|
return queryable;
|
||||||
}
|
}
|
||||||
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11,T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression) where T : class, new()
|
public virtual ISugarQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12> Queryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(Expression<Func<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, bool>> joinExpression) where T : class, new()
|
||||||
{
|
{
|
||||||
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11, T12>();
|
InitMppingInfo<T, T2, T3, T4, T5, T6, T8, T9, T10, T11, T12>();
|
||||||
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11),typeof(T12) };
|
var types = new Type[] { typeof(T2), typeof(T3), typeof(T4), typeof(T5), typeof(T6), typeof(T7), typeof(T8), typeof(T9), typeof(T10), typeof(T11), typeof(T12) };
|
||||||
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig);
|
var queryable = InstanceFactory.GetQueryable<T, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12>(base.CurrentConnectionConfig);
|
||||||
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
base.CreateEasyQueryJoin(joinExpression, types, queryable);
|
||||||
queryable.Where(joinExpression);
|
queryable.Where(joinExpression);
|
||||||
@ -299,23 +303,31 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public virtual List<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
public virtual ISugarQueryable<T> UnionAll<T>(params ISugarQueryable<T>[] queryables) where T : class, new()
|
||||||
{
|
{
|
||||||
if (queryables.IsNullOrEmpty()) return new List<T>();
|
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||||
List<T> result = new List<T>();
|
int i = 1;
|
||||||
|
List<KeyValuePair<string, List<SugarParameter>>> allItems = new List<KeyValuePair<string, List<SugarParameter>>>();
|
||||||
foreach (var item in queryables)
|
foreach (var item in queryables)
|
||||||
{
|
{
|
||||||
var addItems = item.ToList();
|
var sqlObj = item.ToSql();
|
||||||
if (addItems.IsValuable())
|
string sql = sqlObj.Key;
|
||||||
{
|
UtilMethods.RepairReplicationParameters(ref sql, sqlObj.Value.ToArray(), i);
|
||||||
result.AddRange(addItems);
|
if (sqlObj.Value.IsValuable())
|
||||||
}
|
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sql, sqlObj.Value));
|
||||||
|
else
|
||||||
|
allItems.Add(new KeyValuePair<string, List<SugarParameter>>(sql, new List<SugarParameter>()));
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
return result;
|
var allSql = string.Join("UNION ALL \r\n", allItems.Select(it => it.Key));
|
||||||
|
var allParameters = allItems.SelectMany(it => it.Value).ToArray();
|
||||||
|
var resulut = this.Queryable<ExpandoObject>().AS(UtilMethods.GetPackTable(allSql, "unionTable"));
|
||||||
|
resulut.AddParameters(allParameters);
|
||||||
|
return resulut.Select<T>("*");
|
||||||
}
|
}
|
||||||
public virtual List<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
|
public virtual ISugarQueryable<T> UnionAll<T>(List<ISugarQueryable<T>> queryables) where T : class, new()
|
||||||
{
|
{
|
||||||
if (queryables.IsNullOrEmpty()) return new List<T>();
|
Check.Exception(queryables.IsNullOrEmpty(), "UnionAll.queryables is null ");
|
||||||
return UnionAll(queryables.ToArray());
|
return UnionAll(queryables.ToArray());
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
@ -342,7 +354,7 @@ namespace SqlSugar
|
|||||||
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
Check.Exception(columnDictionary == null || columnDictionary.Count == 0, "Insertable.columnDictionary can't be null");
|
||||||
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
var insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(columnDictionary));
|
||||||
var columns = columnDictionary.Select(it => it.Key).ToList();
|
var columns = columnDictionary.Select(it => it.Key).ToList();
|
||||||
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c,StringComparison.CurrentCultureIgnoreCase))); ;
|
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase))); ;
|
||||||
}
|
}
|
||||||
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
public virtual IInsertable<T> Insertable<T>(dynamic insertDynamicObject) where T : class, new()
|
||||||
{
|
{
|
||||||
@ -353,10 +365,10 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var columns= ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
var columns = ((object)insertDynamicObject).GetType().GetProperties().Select(it => it.Name).ToList();
|
||||||
Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null");
|
Check.Exception(columns.IsNullOrEmpty(), "Insertable.updateDynamicObject can't be null");
|
||||||
T insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject));
|
T insertObject = this.RewritableMethods.DeserializeObject<T>(this.RewritableMethods.SerializeObject(insertDynamicObject));
|
||||||
return this.Insertable(insertObject).InsertColumns(it=> columns.Any(c=>it.Equals(c,StringComparison.CurrentCultureIgnoreCase)));
|
return this.Insertable(insertObject).InsertColumns(it => columns.Any(c => it.Equals(c, StringComparison.CurrentCultureIgnoreCase)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -9,32 +9,33 @@ namespace SqlSugar
|
|||||||
public static void ThrowNotSupportedException(string message)
|
public static void ThrowNotSupportedException(string message)
|
||||||
{
|
{
|
||||||
message = message.IsNullOrEmpty() ? new NotSupportedException().Message : message;
|
message = message.IsNullOrEmpty() ? new NotSupportedException().Message : message;
|
||||||
throw new SqlSugarException("SqlSugarException.NotSupportedException:" + message);
|
throw new UtilExceptions("SqlSugarException.NotSupportedException:" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ConnectionConfig(ConnectionConfig config)
|
public static void ConnectionConfig(ConnectionConfig config)
|
||||||
{
|
{
|
||||||
if (config == null || config.ConnectionString.IsNullOrEmpty() || config.DbType.IsNullOrEmpty())
|
if (config == null || config.ConnectionString.IsNullOrEmpty() || config.DbType.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
throw new SqlSugarException("SqlSugarException.ArgumentNullException:" + ErrorMessage.ConnectionConfigIsNull);
|
throw new UtilExceptions("SqlSugarException.ArgumentNullException:" + ErrorMessage.ConnectionConfigIsNull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ArgumentNullException(object checkObj, string message)
|
public static void ArgumentNullException(object checkObj, string message)
|
||||||
{
|
{
|
||||||
if (checkObj == null)
|
if (checkObj == null)
|
||||||
throw new SqlSugarException("SqlSugarException.ArgumentNullException:" + message);
|
throw new UtilExceptions("SqlSugarException.ArgumentNullException:" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ArgumentNullException(object [] checkObj, string message)
|
public static void ArgumentNullException(object [] checkObj, string message)
|
||||||
{
|
{
|
||||||
if (checkObj == null|| checkObj.Length==0)
|
if (checkObj == null|| checkObj.Length==0)
|
||||||
throw new SqlSugarException("SqlSugarException.ArgumentNullException:" + message);
|
throw new UtilExceptions("SqlSugarException.ArgumentNullException:" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Exception(bool isException, string message, params string[] args)
|
public static void Exception(bool isException, string message, params string[] args)
|
||||||
{
|
{
|
||||||
if (isException)
|
if (isException)
|
||||||
throw new SqlSugarException(string.Format(message, args));
|
throw new UtilExceptions(string.Format(message, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -58,7 +58,6 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string NotSupportedArray
|
public static string NotSupportedArray
|
||||||
{
|
{
|
||||||
get
|
get
|
@ -7,7 +7,6 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
internal static class IsWhatExtensions
|
internal static class IsWhatExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
public static bool IsInRange(this int thisValue, int begin, int end)
|
public static bool IsInRange(this int thisValue, int begin, int end)
|
||||||
{
|
{
|
||||||
return thisValue >= begin && thisValue <= end;
|
return thisValue >= begin && thisValue <= end;
|
@ -82,11 +82,4 @@ namespace SqlSugar
|
|||||||
return method.ReflectedType;
|
return method.ReflectedType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static class ReflectionCore
|
|
||||||
{
|
|
||||||
public static Assembly Load(string name)
|
|
||||||
{
|
|
||||||
return Assembly.Load(name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,10 +4,13 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
internal static class PubConst
|
internal static class UtilConstants
|
||||||
{
|
{
|
||||||
internal const string AssemblyName = "SqlSugar";
|
|
||||||
internal const string Space = " ";
|
internal const string Space = " ";
|
||||||
|
internal const string AssemblyName = "SqlSugar";
|
||||||
|
internal const string OrderReplace = "{$:OrderByString:$}";
|
||||||
|
|
||||||
internal static Type StringType = typeof(string);
|
internal static Type StringType = typeof(string);
|
||||||
internal static Type ShortType = typeof(short);
|
internal static Type ShortType = typeof(short);
|
||||||
internal static Type IntType = typeof(int);
|
internal static Type IntType = typeof(int);
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public static class PubConvert
|
public static class UtilConvert
|
||||||
{
|
{
|
||||||
public static int ObjToInt(this object thisValue)
|
public static int ObjToInt(this object thisValue)
|
||||||
{
|
{
|
@ -5,18 +5,18 @@ using System.Text;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class SqlSugarException : Exception
|
public class UtilExceptions : Exception
|
||||||
{
|
{
|
||||||
public SqlSugarException(string message)
|
public UtilExceptions(string message)
|
||||||
: base(message){}
|
: base(message){}
|
||||||
|
|
||||||
public SqlSugarException(SqlSugarClient context,string message, string sql)
|
public UtilExceptions(SqlSugarClient context,string message, string sql)
|
||||||
: base(GetMessage(context, message, sql)) {}
|
: base(GetMessage(context, message, sql)) {}
|
||||||
|
|
||||||
public SqlSugarException(SqlSugarClient context, string message, string sql, object pars)
|
public UtilExceptions(SqlSugarClient context, string message, string sql, object pars)
|
||||||
: base(GetMessage(context,message, sql, pars)){}
|
: base(GetMessage(context,message, sql, pars)){}
|
||||||
|
|
||||||
public SqlSugarException(SqlSugarClient context, string message, object pars)
|
public UtilExceptions(SqlSugarClient context, string message, object pars)
|
||||||
: base(GetMessage(context,message, pars)){}
|
: base(GetMessage(context,message, pars)){}
|
||||||
|
|
||||||
private static string GetMessage(SqlSugarClient context, string message, object pars)
|
private static string GetMessage(SqlSugarClient context, string message, object pars)
|
||||||
@ -30,7 +30,6 @@ namespace SqlSugar
|
|||||||
return reval;
|
return reval;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetMessage(SqlSugarClient context, string message, string sql, object pars)
|
private static string GetMessage(SqlSugarClient context, string message, string sql, object pars)
|
||||||
{
|
{
|
||||||
if (pars == null)
|
if (pars == null)
|
||||||
@ -43,16 +42,14 @@ namespace SqlSugar
|
|||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetMessage(string message, string sql)
|
private static string GetMessage(string message, string sql)
|
||||||
{
|
{
|
||||||
var reval = GetLineMessage("message ", message) + GetLineMessage("ORM Sql", sql);
|
var reval = GetLineMessage("message ", message) + GetLineMessage("ORM Sql", sql);
|
||||||
return reval;
|
return reval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetLineMessage(string key, string value)
|
private static string GetLineMessage(string key, string value)
|
||||||
{
|
{
|
||||||
return string.Format("{0} : 【{1}】\r\n", key, value);
|
return string.Format("{0} : '{1}' \r\n", key, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ using System.Reflection;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
namespace SqlSugar
|
namespace SqlSugar
|
||||||
{
|
{
|
||||||
public class PubMethod
|
public class UtilMethods
|
||||||
{
|
{
|
||||||
internal static Type GetUnderType(Type oldType)
|
internal static Type GetUnderType(Type oldType)
|
||||||
{
|
{
|
||||||
@ -36,7 +36,6 @@ namespace SqlSugar
|
|||||||
return unType != null;
|
return unType != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal static T IsNullReturnNew<T>(T returnObj) where T : new()
|
internal static T IsNullReturnNew<T>(T returnObj) where T : new()
|
||||||
{
|
{
|
||||||
if (returnObj.IsNullOrEmpty())
|
if (returnObj.IsNullOrEmpty())
|
||||||
@ -55,5 +54,25 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
return (T)Convert.ChangeType(obj, typeof(T));
|
return (T)Convert.ChangeType(obj, typeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static void RepairReplicationParameters(ref string appendSql, SugarParameter[] parameters, int addIndex)
|
||||||
|
{
|
||||||
|
if (appendSql.IsValuable() && parameters.IsValuable())
|
||||||
|
{
|
||||||
|
foreach (var parameter in parameters.OrderByDescending(it => it.ParameterName.Length))
|
||||||
|
{
|
||||||
|
//Compatible with.NET CORE parameters case
|
||||||
|
var name = parameter.ParameterName;
|
||||||
|
string newName = name + addIndex;
|
||||||
|
appendSql = appendSql.Replace(name, newName);
|
||||||
|
parameter.ParameterName = newName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static string GetPackTable(string sql, string shortName)
|
||||||
|
{
|
||||||
|
return string.Format(" ({0}) {1} ", sql, shortName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user