Skip to content

Commit

Permalink
v3.2.812 v3.2.811 #1730 #1727 #1725 #1724 #1712
Browse files Browse the repository at this point in the history
  • Loading branch information
2881099 committed Feb 1, 2024
1 parent 1b807f3 commit 0a6ad65
Show file tree
Hide file tree
Showing 33 changed files with 57 additions and 61 deletions.
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<!--
经常出于版本交叉问题,暂时关闭,在每个项目上设置版本号
<PropertyGroup>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
</PropertyGroup>
-->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<LangVersion>latest</LangVersion>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Title>$(AssemblyName)</Title>
<IsPackable>true</IsPackable>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion Extensions/FreeSql.Generator/FreeSql.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageProjectUrl>https://github.com/2881099/FreeSql</PackageProjectUrl>
<RepositoryUrl>https://github.com/2881099/FreeSql</RepositoryUrl>
<PackageTags>FreeSql DbFirst 实体生成器</PackageTags>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion FreeSql.All/FreeSql.All.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion FreeSql.DbContext/FreeSql.DbContext.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion FreeSql.Repository/FreeSql.Repository.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion FreeSql/FreeSql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
54 changes: 25 additions & 29 deletions FreeSql/Internal/CommonProvider/SelectProvider/Select0Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public abstract partial class Select0Provider
public BaseDiyMemberExpression _diymemexpWithTempQuery;
public Func<DbTransaction> _resolveHookTransaction;

public bool IsDefaultSqlContent => _tables.Count == 1 && _tables[0].Table?.AsTableImpl == null &&
public bool IsDefaultSqlContent => _tables.Count == 1 && _tables[0].Table?.AsTableImpl == null &&
_distinct == false && _is_AsTreeCte == false && _where.Length == 0 && _join.Length == 0 &&
string.IsNullOrWhiteSpace(_orderby) && string.IsNullOrWhiteSpace(_groupby) && string.IsNullOrWhiteSpace(_tosqlAppendContent) &&
_aliasRule == null && _selectExpression == null;
Expand Down Expand Up @@ -241,7 +241,6 @@ public WithTempQueryParser Append(Select0Provider select, SelectTableInfo outsid
public override string ParseExp(Expression[] members)
{
ParseExpMapResult = null;
ParseExpColumnResult = null;
ParseExpMatchedTable = GetOutsideSelectTable(members.FirstOrDefault()?.GetParameter());
if (ParseExpMatchedTable == null) return null;

Expand All @@ -255,14 +254,12 @@ public override string ParseExp(Expression[] members)
if (members.Any() == false)
{
ParseExpMapResult = insideData.InsideMap;
ParseExpColumnResult = ParseExpMapResult.GetColumn();
return $"{ParseExpMatchedTable.Alias}.{insideData.InsideMap.DbNestedField}";
}
var read = insideData.InsideMap;
if (members.Length == 1 && members[0] == ParseExpMatchedTable.Parameter)
{
ParseExpMapResult = read;
ParseExpColumnResult = ParseExpMapResult.GetColumn();
return $"{ParseExpMatchedTable.Alias}.{read.DbNestedField}";
}
for (var a = members[0] == ParseExpMatchedTable.Parameter ? 1 : 0; a < members.Length; a++)
Expand All @@ -271,7 +268,6 @@ public override string ParseExp(Expression[] members)
if (read == null) return null;
}
ParseExpMapResult = read;
ParseExpColumnResult = ParseExpMapResult.GetColumn();
return $"{ParseExpMatchedTable.Alias}.{read.DbNestedField}";
}
public SelectTableInfo GetOutsideSelectTable(ParameterExpression parameterExp)
Expand All @@ -287,26 +283,26 @@ public SelectTableInfo GetOutsideSelectTable(ParameterExpression parameterExp)
}
}

public static MethodInfo _methodSqlExtInternalRawField = typeof(SqlExt).GetMethod("InternalRawField", BindingFlags.NonPublic | BindingFlags.Static);
public static MethodInfo _methodSqlExtInternalRawSql = typeof(SqlExt).GetMethod("InternalRawSql", BindingFlags.NonPublic | BindingFlags.Static);
public Expression ConvertStringPropertyToExpression(string property, bool fromFirstTable = false)
public static MethodInfo _methodSqlExtInternalRawField = typeof(SqlExt).GetMethod("InternalRawField", BindingFlags.NonPublic | BindingFlags.Static);
public static MethodInfo _methodSqlExtInternalRawSql = typeof(SqlExt).GetMethod("InternalRawSql", BindingFlags.NonPublic | BindingFlags.Static);
public Expression ConvertStringPropertyToExpression(string property, bool fromFirstTable = false)
{
if (string.IsNullOrEmpty(property)) return null;
var field = property.Split('.').Select(a => a.Trim()).ToArray();
Expression exp = null;

if (field.Length == 1 && fromFirstTable == false)
{
if (_tables.Count == 1 && _tables[0].Table?.Type == typeof(object))
{
if (_tables.Count == 1 && _tables[0].Table?.Type == typeof(object))
{
//配合 .Select<object>().WithSql("...").WhereDynamicFilter(...)
var tb = _tables[0];
tb.Parameter = Expression.Parameter(tb.Table.Type, tb.Alias);
var rawField = $"{tb.Alias}.{_commonUtils.QuoteSqlName(field[0])}";
return Expression.Call(_methodSqlExtInternalRawField, Expression.Constant(rawField, typeof(string)));
}
var tb = _tables[0];
tb.Parameter = Expression.Parameter(tb.Table.Type, tb.Alias);
var rawField = $"{tb.Alias}.{_commonUtils.QuoteSqlName(field[0])}";
return Expression.Call(_methodSqlExtInternalRawField, Expression.Constant(rawField, typeof(string)));
}

foreach (var tb in _tables)
foreach (var tb in _tables)
{
if (tb.Table.ColumnsByCs.TryGetValue(field[0], out var col) &&
tb.Table.Properties.TryGetValue(field[0], out var prop))
Expand Down Expand Up @@ -382,7 +378,7 @@ internal Select0Provider SetSameSelectPendingShareData(List<NativeTuple<string,
{
var last = _SameSelectPendingShareData.Last();
if (last == null && _SameSelectPendingShareData.Count > 1) last = _SameSelectPendingShareData[_SameSelectPendingShareData.Count - 2];
if (last != null)
if (last != null)
_params.AddRange(last.Item2 ?? new DbParameter[0]);
}
return this;
Expand Down Expand Up @@ -874,11 +870,11 @@ protected List<Dictionary<Type, string>> GetTableRuleUnions()
var unions = new List<Dictionary<Type, string>>();
var trs = _tableRules.Any() ? _tableRules : new List<Func<Type, string, string>>(new[] { new Func<Type, string, string>((type, oldname) => null) });

if (trs.Count == 1 && _tables.Any(a => a.Table != null && a.Table.AsTableImpl != null &&
if (trs.Count == 1 && _tables.Any(a => a.Table != null && a.Table.AsTableImpl != null &&
string.IsNullOrWhiteSpace(trs[0](a.Table.Type, a.Table.AsTableImpl != null ? null : a.Table.DbName)) == true))
{
DateTime? DateTimeAsTableImplStart = null, DateTimeAsTableImplEnd = null;
string[] LocalGetTableNames(SelectTableInfo tb)
string[] LocalGetTableNames(SelectTableInfo tb)
{
var trname = trs[0](tb.Table.Type, tb.Table.AsTableImpl != null ? null : tb.Table.DbName);
if (tb.Table.AsTableImpl != null && string.IsNullOrWhiteSpace(trname) == true)
Expand Down Expand Up @@ -919,17 +915,17 @@ string[] LocalGetTableNames(SelectTableInfo tb)
}
return new string[] { tb.Table.DbName };
}
var tbnames = _tables.Where(a => a.Type != SelectTableInfoType.Parent).GroupBy(a => a.Table.Type).Select(g => _tables.Where(a => a.Table.Type == g.Key).FirstOrDefault()).Select(a => new { Tb = a, Names = LocalGetTableNames(a) }).ToList();
var tbnames = _tables.Where(a => a.Type != SelectTableInfoType.Parent).GroupBy(a => a.Table.Type).Select(g => _tables.Where(a => a.Table.Type == g.Key).FirstOrDefault()).Select(a => new { Tb = a, Names = LocalGetTableNames(a) }).ToList();
if (DateTimeAsTableImplStart != null && DateTimeAsTableImplEnd != null && tbnames.Where(a => a.Names.Length > 1).Count() > 1)
{
tbnames = tbnames.Select(a => new { a.Tb, Names = a.Tb.Table.AsTableImpl?.GetTableNamesByColumnValueRange(DateTimeAsTableImplStart, DateTimeAsTableImplEnd) ?? a.Names }).ToList();
}
var dict = new Dictionary<Type, string>();
var dict = new Dictionary<Type, string>();
tbnames.ForEach(a =>
{
dict.Add(a.Tb.Table.Type, a.Names[0]);
});
unions.Add(dict);
unions.Add(dict);
for (var a = 0; a < tbnames.Count; a++)
{
if (tbnames[a].Names.Length <= 1) continue;
Expand All @@ -941,7 +937,7 @@ string[] LocalGetTableNames(SelectTableInfo tb)
dict = new Dictionary<Type, string>();
foreach (var uit in unions[d])
dict.Add(uit.Key, uit.Key == tbnames[a].Tb.Table.Type ? tbnames[a].Names[b] : uit.Value);
unions.Add(dict);
unions.Add(dict);
}
}
}
Expand All @@ -968,7 +964,7 @@ string[] LocalGetTableNames(SelectTableInfo tb)
}
if (ignore) unions.RemoveAt(uidx);
}
}
}
return unions;
}
if (trs.Any() == false) trs.Add(new Func<Type, string, string>((type, oldname) => null));
Expand Down Expand Up @@ -1082,7 +1078,7 @@ void ParseFilter(DynamicFilterLogic logic, DynamicFilterInfo fi, bool isend)
if (fiValue0Method == null) throw new ArgumentException(CoreStrings.NotFound_Static_MethodName(fiValueCustomArray[0]));
if (MethodIsDynamicFilterCustomAttribute(fiValue0Method) == false) throw new ArgumentException(CoreStrings.Custom_StaticMethodName_NotSet_DynamicFilterCustom(fiValueCustomArray[0]));
var fiValue0MethodReturn = fiValue0Method?.Invoke(null, fiValue0Method.GetParameters()
.Select(a => a.ParameterType == typeof(object) ? (object)this :
.Select(a => a.ParameterType == typeof(object) ? (object)this :
(a.ParameterType == typeof(string) ? (object)(fi.Value?.ToString()) : (object)null))
.ToArray());
exp = fiValue0MethodReturn is Expression expression ? expression : Expression.Call(_methodSqlExtInternalRawSql, Expression.Constant(fiValue0MethodReturn?.ToString(), typeof(string)));
Expand All @@ -1103,12 +1099,12 @@ void ParseFilter(DynamicFilterLogic logic, DynamicFilterInfo fi, bool isend)
{
var valueType = fi.Value?.GetType();
if (Utils.dicExecuteArrayRowReadClassOrTuple.ContainsKey(valueType)) exp = Expression.Convert(exp, valueType);
else if (valueType.FullName == "System.Text.Json.JsonElement")
else if (valueType.FullName == "System.Text.Json.JsonElement")
{
var valueKind = valueType.GetProperty("ValueKind").GetValue(fi.Value, null).ToString();
var valueKind = valueType.GetProperty("ValueKind").GetValue(fi.Value, null).ToString();
if (valueKind == "Number") exp = Expression.Convert(exp, typeof(decimal));
}
}
}
}
break;
}
switch (fi.Operator)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<SignAssembly>False</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Title>$(AssemblyName)</Title>
<IsPackable>true</IsPackable>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Title>$(AssemblyName)</Title>
<IsPackable>true</IsPackable>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>
<Version>3.2.812-preview20240201</Version>
<Version>3.2.812</Version>
<PackageReadmeFile>readme.md</PackageReadmeFile>
</PropertyGroup>

Expand Down
Loading

0 comments on commit 0a6ad65

Please sign in to comment.