FreeSql ISelect/IUpdate/IInsert/IDelete 增加 AsTable 方法,实现分表

This commit is contained in:
28810
2019-03-05 21:04:52 +08:00
parent f9fef12d37
commit 90f69f1b57
38 changed files with 813 additions and 87 deletions

View File

@ -69,5 +69,21 @@ namespace FreeSql.Tests.Oracle {
//var item = g.oracle.Insert<Topic>(new Topic { Title = "xxxx", CreateTime = DateTime.Now }).ExecuteInserted();
//Assert.Equal(item[0].Id, delete.Where(a => a.Id == item[0].Id).ExecuteDeleted()[0].Id);
}
[Fact]
public void AsTable() {
Assert.Null(g.oracle.Delete<Topic>().ToSql());
var sql = g.oracle.Delete<Topic>(new[] { 1, 2 }).AsTable(a => "TopicAsTable").ToSql();
Assert.Equal("DELETE FROM \"TopicAsTable\" WHERE (\"ID\" = 1 OR \"ID\" = 2)", sql);
sql = g.oracle.Delete<Topic>(new Topic { Id = 1, Title = "test" }).AsTable(a => "TopicAsTable").ToSql();
Assert.Equal("DELETE FROM \"TopicAsTable\" WHERE (\"ID\" = 1)", sql);
sql = g.oracle.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).AsTable(a => "TopicAsTable").ToSql();
Assert.Equal("DELETE FROM \"TopicAsTable\" WHERE (\"ID\" = 1 OR \"ID\" = 2)", sql);
sql = g.oracle.Delete<Topic>(new { id = 1 }).AsTable(a => "TopicAsTable").ToSql();
Assert.Equal("DELETE FROM \"TopicAsTable\" WHERE (\"ID\" = 1)", sql);
}
}
}