mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
- 修复 实体类拥有构造参数时,ToList\<DTO\> 映射查询无效的 bug;
This commit is contained in:
parent
dad05d83c9
commit
4ef38817ff
@ -15,6 +15,7 @@ namespace FreeSql.Tests
|
||||
{
|
||||
public ts_record parent { get; set; }
|
||||
}
|
||||
public record ts_record_dto(DateTime Date, int TemperatureC, string Summary);
|
||||
|
||||
[Fact]
|
||||
public void LeftJoinNull01()
|
||||
@ -24,6 +25,8 @@ namespace FreeSql.Tests
|
||||
fsql.Delete<ts_record>().Where("1=1").ExecuteAffrows();
|
||||
fsql.Insert(new ts_record(DateTime.Now, 1, 2, "123")).ExecuteAffrows();
|
||||
var fores = fsql.Select<ts_record>().ToList();
|
||||
var fores_dtos1 = fsql.Select<ts_record>().ToList<ts_record_dto>();
|
||||
var fores_dtos2 = fsql.Select<ts_record>().ToList(a => new ts_record_dto(a.Date, a.TemperatureC, a.Summary));
|
||||
|
||||
|
||||
|
||||
|
@ -273,9 +273,9 @@ namespace FreeSql.Internal
|
||||
{
|
||||
if (a.NodeType != ExpressionType.Constant) return true;
|
||||
var constVal = (a as ConstantExpression)?.Value;
|
||||
if (constVal == null) return true;
|
||||
if (object.Equals(constVal, a.Type.CreateInstanceGetDefaultValue()) == false) return true;
|
||||
return false;
|
||||
if (constVal == null) return false; //- 修复 实体类拥有构造参数时,ToList\<DTO\> 映射查询无效的 bug;
|
||||
if (object.Equals(constVal, a.Type.CreateInstanceGetDefaultValue())) return false;
|
||||
return true;
|
||||
})
|
||||
))
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user