mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 10:42:52 +08:00
- fix string[] UseJsonMap bug;#653
This commit is contained in:
parent
976fa15879
commit
26b562410c
@ -312,6 +312,11 @@ namespace base_entity
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
}
|
||||
record TestClass(string Name)
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string[] Tags { get; init; } = Array.Empty<string>();
|
||||
}
|
||||
static void Main(string[] args)
|
||||
{
|
||||
#region 初始化 IFreeSql
|
||||
@ -361,6 +366,23 @@ namespace base_entity
|
||||
BaseEntity.Initialization(fsql, () => _asyncUow.Value);
|
||||
#endregion
|
||||
|
||||
|
||||
fsql.UseJsonMap();
|
||||
|
||||
fsql.CodeFirst.ConfigEntity<TestClass>(cf =>
|
||||
{
|
||||
cf.Property(p => p.Name).IsNullable(false);
|
||||
cf.Property(p => p.Tags).JsonMap();
|
||||
});
|
||||
|
||||
fsql.Insert(new TestClass("test 1")
|
||||
{
|
||||
Tags = new[] { "a", "b" },
|
||||
})
|
||||
.ExecuteAffrows();
|
||||
var records = fsql.Queryable<TestClass>().ToList();
|
||||
|
||||
|
||||
InitData();
|
||||
InitData();
|
||||
|
||||
|
@ -800,5 +800,14 @@
|
||||
<param name="that"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
|
||||
<summary>
|
||||
批量注入 Repository,可以参考代码自行调整
|
||||
</summary>
|
||||
<param name="services"></param>
|
||||
<param name="globalDataFilter"></param>
|
||||
<param name="assemblies"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
</members>
|
||||
</doc>
|
||||
|
@ -2018,9 +2018,9 @@ namespace FreeSql.Internal
|
||||
{
|
||||
var returnTarget = Expression.Label(typeof(object));
|
||||
var valueExp = Expression.Variable(typeof(object), "locvalue");
|
||||
Func<Expression> funcGetExpression = () =>
|
||||
Expression LocalFuncGetExpression(bool ignoreArray = false)
|
||||
{
|
||||
if (type.IsArray)
|
||||
if (!ignoreArray && type.IsArray)
|
||||
{
|
||||
switch (type.FullName)
|
||||
{
|
||||
@ -2059,6 +2059,9 @@ namespace FreeSql.Internal
|
||||
return Expression.IfThenElse(
|
||||
Expression.TypeEqual(valueExp, type),
|
||||
Expression.Return(returnTarget, valueExp),
|
||||
Expression.IfThenElse(
|
||||
Expression.TypeEqual(valueExp, typeof(string)), //JSON
|
||||
LocalFuncGetExpression(true),
|
||||
Expression.Block(
|
||||
new[] { arrNewExp, arrExp, arrLenExp, arrXExp, arrReadValExp },
|
||||
Expression.Assign(arrExp, Expression.TypeAs(valueExp, typeof(Array))),
|
||||
@ -2087,6 +2090,7 @@ namespace FreeSql.Internal
|
||||
),
|
||||
Expression.Return(returnTarget, arrNewExp)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
var typeOrg = type;
|
||||
@ -2387,7 +2391,7 @@ namespace FreeSql.Internal
|
||||
Expression.Equal(valueExp, Expression.Constant(DBNull.Value))
|
||||
),
|
||||
Expression.Return(returnTarget, Expression.Convert(Expression.Default(type), typeof(object))),
|
||||
funcGetExpression()
|
||||
LocalFuncGetExpression()
|
||||
),
|
||||
Expression.Label(returnTarget, Expression.Default(typeof(object)))
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user