Merge branch 'master' of github.com:dotnetcore/FreeSql

This commit is contained in:
igeekfan
2022-06-10 03:06:03 +08:00
30 changed files with 219 additions and 210 deletions

View File

@ -12,26 +12,6 @@ namespace FreeSql.Tests.Odbc.Default
public class OdbcCodeFirstTest
{
[Fact]
public void Test_0String()
{
var fsql = g.odbc;
fsql.Delete<test_0string01>().Where("1=1").ExecuteAffrows();
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).ExecuteAffrows());
Assert.Equal(1, fsql.Insert(new test_0string01 { name = @"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000" }).NoneParameter().ExecuteAffrows());
var list = fsql.Select<test_0string01>().ToList();
Assert.Equal(2, list.Count);
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[0].name);
Assert.Equal(@"1.0000\0.0000\0.0000\0.0000\1.0000\0.0000", list[1].name);
}
class test_0string01
{
public Guid id { get; set; }
public string name { get; set; }
}
[Fact]
public void _字段()
{

View File

@ -1,4 +1,4 @@
using FreeSql.DataAnnotations;
using FreeSql.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -83,6 +83,13 @@ namespace FreeSql.Tests.SqlServerExpression
IEnumerable<int> testlinqlist = new List<int>(new[] { 1, 2, 3 });
var testlinq = select.Where(a => testlinqlist.Contains(a.testFieldInt)).ToList();
var testlinqlist2 = new List<TableAllType>(new[] {
new TableAllType{Id = 1,},
new TableAllType{Id = 2,},
new TableAllType{Id = 3,}
}).Select(a => a.Id).ToArray().Distinct();
var testlinq2 = select.Where(a => testlinqlist2.Contains(a.testFieldInt) && a.testFieldByte == 1).ToList();
//in not in
var sql111 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt)).ToList();
var sql112 = select.Where(a => new[] { 1, 2, 3 }.Contains(a.testFieldInt) == false).ToList();

View File

@ -1126,6 +1126,24 @@ WHERE (((cast(a.""Id"" as character)) in (SELECT b.""Title""
[Fact]
public void AsTable()
{
var fsql = g.sqlite;
var asTableSubSql = fsql.Select<TestTypeParentInfo>().AsTable((_, old) => $"{old}_01").ToSql(a => new
{
a.Id,
max = fsql.Select<TestTypeInfo>().Max(b => b.Guid),
any = a.Types.Any(b => b.Name == "xx"),
any2 = a.Types.AsSelect().Any(b => b.Name == "xx"),
sub = fsql.Select<TestTypeInfo>().Where(b => b.Guid == a.Id).ToList()
});
Assert.Equal(@"SELECT a.""Id"" as1, ifnull((SELECT max(a.""Guid"")
FROM ""TestTypeInfo_01"" a), 0) as2, exists(SELECT 1
FROM ""TestTypeInfo_01"" b
WHERE (b.""ParentId"" = a.""Id"") AND (b.""Name"" = 'xx')
limit 0,1) as3, exists(SELECT 1
FROM ""TestTypeInfo_01"" b
WHERE (b.""Name"" = 'xx') AND (b.""ParentId"" = a.""Id"")
limit 0,1) as4
FROM ""TestTypeParentInfo_01"" a", asTableSubSql);
var listt = select.AsTable((a, b) => "(select * from tb_topic where clicks > 10)").Page(1, 10).ToList();