- 完善 Select`2-10 多表查询对象,增加 First(select)/ToOne(select)/First\<Dto\> 方法;

This commit is contained in:
28810
2019-12-19 13:46:11 +08:00
parent eb4bbd9448
commit ec25ccea86
25 changed files with 376 additions and 212 deletions

View File

@ -133,6 +133,33 @@ namespace FreeSql.Tests.DataAnnotations
public bool isignore { get; set; }
}
[Fact]
public void AutoPrimary()
{
var tb1 = g.mysql.CodeFirst.GetTableByEntity(typeof(pkfalse_t1));
var tb2 = g.mysql.CodeFirst.GetTableByEntity(typeof(pkfalse_t2));
var tb3 = g.mysql.CodeFirst.GetTableByEntity(typeof(pkfalse_t3));
Assert.True(tb1.ColumnsByCs["id"].Attribute.IsPrimary);
Assert.False(tb2.ColumnsByCs["id"].Attribute.IsPrimary);
Assert.True(tb3.ColumnsByCs["id"].Attribute.IsPrimary);
}
class pkfalse_t1
{
public int id { get; set; }
}
class pkfalse_t2
{
[Column(IsPrimary = false)]
public int id { get; set; }
}
class pkfalse_t3
{
[Column(IsPrimary = true)]
public int id { get; set; }
}
[Fact]
public void CanInsert_CanUpdate()
{

View File

@ -128,6 +128,33 @@ namespace FreeSql.Tests.DataAnnotations
[Column(IsIgnore = true)]
public bool isignore { get; set; }
}
[Fact]
public void AutoPrimary()
{
var tb1 = g.sqlserver.CodeFirst.GetTableByEntity(typeof(pkfalse_t1));
var tb2 = g.sqlserver.CodeFirst.GetTableByEntity(typeof(pkfalse_t2));
var tb3 = g.sqlserver.CodeFirst.GetTableByEntity(typeof(pkfalse_t3));
Assert.True(tb1.ColumnsByCs["id"].Attribute.IsPrimary);
Assert.False(tb2.ColumnsByCs["id"].Attribute.IsPrimary);
Assert.True(tb3.ColumnsByCs["id"].Attribute.IsPrimary);
}
class pkfalse_t1
{
public int id { get; set; }
}
class pkfalse_t2
{
[Column(IsPrimary = false)]
public int id { get; set; }
}
class pkfalse_t3
{
[Column(IsPrimary = true)]
public int id { get; set; }
}
}
}

View File

@ -43,21 +43,6 @@ namespace FreeSql.Tests
// fsql.Select<ut3_t1>().ToList();
//}
var tb1 = g.sqlite.CodeFirst.GetTableByEntity(typeof(pkfalse_t1));
var tb2 = g.sqlite.CodeFirst.GetTableByEntity(typeof(pkfalse_t2));
}
class pkfalse_t1
{
[Column(IsPrimary = false)]
public int id { get; set; }
}
class pkfalse_t2
{
[Column(IsPrimary = true)]
public int id { get; set; }
}
class ut3_t1
@ -66,7 +51,6 @@ namespace FreeSql.Tests
public int id { get; set; }
public string name { get; set; }
}
class ut3_t2
{
[Column(IsIdentity = true)]