v3.2.666-preview20220726 #1193

This commit is contained in:
2881099
2022-07-25 15:19:44 +08:00
parent 9b23da6581
commit 9767656a87
5 changed files with 280 additions and 185 deletions

View File

@ -0,0 +1,58 @@
using FreeSql.DataAnnotations;
using System;
using System.Linq;
using Xunit;
namespace FreeSql.Tests.Issues
{
public class _1193
{
[Table(Name = "MyData_1193")]
public class MyDataEntity
{
[Column(IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
public string? Name { get; set; }
}
public class MyDataDto : MyDataDtoError
{
public MyDataDto() : base(0) { }
public MyDataDto(int id) : base(id) { }
}
public class MyDataDtoError
{
public MyDataDtoError(int id)
{
Id = id;
}
public MyDataDtoError(int id, string title)
{
Id = id;
Title = title;
}
public int Id { get; set; }
public string? Name { get; set; }
public string? Title { get; }
}
[Fact]
public void TestYear()
{
var fsql = g.sqlite;
fsql.GetRepository<MyDataEntity>().Insert(new MyDataEntity { Name = "my name" + DateTime.Now.ToString("yyyyMMddTHHmmss") });
var uowm = new UnitOfWorkManager(fsql);
using var uow = uowm.Begin();
var repository = uow.Orm.GetRepository<MyDataEntity, int>();
var firstData = repository.Select.First((o) => new MyDataDto(o.Id) { Name = o.Name });
var errorData = repository.Select.First((o) => new MyDataDtoError(o.Id, o.Name) { Name = o.Name });
}
}
}