-
Notifications
You must be signed in to change notification settings - Fork 865
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 增加 PostgreSQL 的 Odbc 访问提供,相比 FreeSql.Provider.PostgreSQL 支持的类型更少; - 增加 通用的 Odbc 访问提供,不能迁移实体到数据库,不能 Skip 这样来分页,理论上能 crud 所有 odbc 数据库;
- Loading branch information
28810
authored and
28810
committed
Sep 20, 2019
1 parent
90458cc
commit dcf1da3
Showing
97 changed files
with
18,833 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
FreeSql.Tests/FreeSql.Tests.Provider.Odbc/Default/Curd/OdbcDeleteTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using FreeSql.DataAnnotations; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace FreeSql.Tests.Odbc.Default | ||
{ | ||
public class OdbcDeleteTest | ||
{ | ||
IDelete<Topic> delete => g.odbc.Delete<Topic>(); //�������� | ||
|
||
[Table(Name = "tb_topic22211")] | ||
class Topic | ||
{ | ||
[Column(IsIdentity = true, IsPrimary = true)] | ||
public int Id { get; set; } | ||
public int? Clicks { get; set; } | ||
public TestTypeInfo Type { get; set; } | ||
public string Title { get; set; } | ||
public DateTime CreateTime { get; set; } | ||
} | ||
|
||
[Fact] | ||
public void Dywhere() | ||
{ | ||
Assert.Null(g.odbc.Delete<Topic>().ToSql()); | ||
var sql = g.odbc.Delete<Topic>(new[] { 1, 2 }).ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1 OR [Id] = 2)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new Topic { Id = 1, Title = "test" }).ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1 OR [Id] = 2)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new { id = 1 }).ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1)", sql); | ||
} | ||
|
||
[Fact] | ||
public void Where() | ||
{ | ||
var sql = delete.Where(a => a.Id == 1).ToSql().Replace("\r\n", ""); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1)", sql); | ||
|
||
sql = delete.Where("id = @id", new { id = 1 }).ToSql().Replace("\r\n", ""); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE (id = @id)", sql); | ||
|
||
var item = new Topic { Id = 1, Title = "newtitle" }; | ||
sql = delete.Where(item).ToSql().Replace("\r\n", ""); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] = 1)", sql); | ||
|
||
var items = new List<Topic>(); | ||
for (var a = 0; a < 10; a++) items.Add(new Topic { Id = a + 1, Title = $"newtitle{a}", Clicks = a * 100 }); | ||
|
||
sql = delete.Where(items).ToSql().Replace("\r\n", ""); | ||
Assert.Equal("DELETE FROM [tb_topic22211] WHERE ([Id] IN (1,2,3,4,5,6,7,8,9,10))", sql); | ||
} | ||
[Fact] | ||
public void WhereExists() | ||
{ | ||
|
||
} | ||
[Fact] | ||
public void ExecuteAffrows() | ||
{ | ||
|
||
var id = g.odbc.Insert<Topic>(new Topic { Title = "xxxx", CreateTime = DateTime.Now }).ExecuteIdentity(); | ||
Assert.Equal(1, delete.Where(a => a.Id == id).ExecuteAffrows()); | ||
} | ||
|
||
[Fact] | ||
public void AsTable() | ||
{ | ||
Assert.Null(g.odbc.Delete<Topic>().ToSql()); | ||
var sql = g.odbc.Delete<Topic>(new[] { 1, 2 }).AsTable(a => "tb_topic22211AsTable").ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211AsTable] WHERE ([Id] = 1 OR [Id] = 2)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new Topic { Id = 1, Title = "test" }).AsTable(a => "tb_topic22211AsTable").ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211AsTable] WHERE ([Id] = 1)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new[] { new Topic { Id = 1, Title = "test" }, new Topic { Id = 2, Title = "test" } }).AsTable(a => "tb_topic22211AsTable").ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211AsTable] WHERE ([Id] = 1 OR [Id] = 2)", sql); | ||
|
||
sql = g.odbc.Delete<Topic>(new { id = 1 }).AsTable(a => "tb_topic22211AsTable").ToSql(); | ||
Assert.Equal("DELETE FROM [tb_topic22211AsTable] WHERE ([Id] = 1)", sql); | ||
} | ||
} | ||
} |
Oops, something went wrong.