mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 02:32:50 +08:00
- 优化 MapRead 对 NULL 字段的处理;
This commit is contained in:
parent
d01cbdd8df
commit
58be3b77f3
@ -10,6 +10,41 @@ namespace FreeSql.Tests
|
|||||||
{
|
{
|
||||||
public class UnitTest4
|
public class UnitTest4
|
||||||
{
|
{
|
||||||
|
[Fact]
|
||||||
|
public void LeftJoinNull01()
|
||||||
|
{
|
||||||
|
var fsql = g.sqlite;
|
||||||
|
fsql.Delete<leftjoin_null01>().Where("1=1").ExecuteAffrows();
|
||||||
|
fsql.Delete<leftjoin_null02>().Where("1=1").ExecuteAffrows();
|
||||||
|
|
||||||
|
var item = new leftjoin_null01 { name = "xx01" };
|
||||||
|
fsql.Insert(item).ExecuteAffrows();
|
||||||
|
|
||||||
|
var sel1 = fsql.Select<leftjoin_null01, leftjoin_null02>()
|
||||||
|
.LeftJoin((a, b) => a.id == b.null01_id)
|
||||||
|
.First((a, b) => new
|
||||||
|
{
|
||||||
|
a.id,
|
||||||
|
a.name,
|
||||||
|
id2 = (Guid?)b.id,
|
||||||
|
time2 = (DateTime?)b.time
|
||||||
|
});
|
||||||
|
Assert.Null(sel1.id2);
|
||||||
|
Assert.Null(sel1.time2);
|
||||||
|
}
|
||||||
|
|
||||||
|
class leftjoin_null01
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public string name { get; set; }
|
||||||
|
}
|
||||||
|
class leftjoin_null02
|
||||||
|
{
|
||||||
|
public Guid id { get; set; }
|
||||||
|
public Guid null01_id { get; set; }
|
||||||
|
public DateTime time { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestHzyTuple()
|
public void TestHzyTuple()
|
||||||
|
@ -178,14 +178,14 @@ namespace FreeSql.Internal
|
|||||||
parent.Property = parentProp; //若不加此行,会引用 GroupBy(..).ToList(a => new Dto { key = a.Key }) null 错误,CopyTo 之后 Property 变为 null
|
parent.Property = parentProp; //若不加此行,会引用 GroupBy(..).ToList(a => new Dto { key = a.Key }) null 错误,CopyTo 之后 Property 变为 null
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
parent.CsType = exp.Type;
|
if (parent.CsType == null) parent.CsType = exp.Type;
|
||||||
parent.DbField = ExpressionLambdaToSql(exp, getTSC());
|
parent.DbField = ExpressionLambdaToSql(exp, getTSC());
|
||||||
field.Append(", ").Append(parent.DbField);
|
field.Append(", ").Append(parent.DbField);
|
||||||
if (index >= 0) field.Append(_common.FieldAsAlias($"as{++index}"));
|
if (index >= 0) field.Append(_common.FieldAsAlias($"as{++index}"));
|
||||||
else if (index == ReadAnonymousFieldAsCsName && string.IsNullOrEmpty(parent.CsName) == false &&
|
else if (index == ReadAnonymousFieldAsCsName && string.IsNullOrEmpty(parent.CsName) == false &&
|
||||||
parent.DbField.EndsWith(_common.QuoteSqlName(parent.CsName), StringComparison.CurrentCultureIgnoreCase) == false //DbField 和 CsName 相同的时候,不处理
|
parent.DbField.EndsWith(_common.QuoteSqlName(parent.CsName), StringComparison.CurrentCultureIgnoreCase) == false //DbField 和 CsName 相同的时候,不处理
|
||||||
) field.Append(_common.FieldAsAlias(parent.CsName));
|
) field.Append(_common.FieldAsAlias(parent.CsName));
|
||||||
parent.MapType = SearchColumnByField(_tables, null, parent.DbField)?.Attribute.MapType ?? exp.Type;
|
if (parent.MapType == null) parent.MapType = SearchColumnByField(_tables, null, parent.DbField)?.Attribute.MapType ?? exp.Type;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user