mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
add access like test.
This commit is contained in:
parent
4b15cfb96f
commit
a35ddd30cb
@ -1,4 +1,4 @@
|
|||||||
using FreeSql.DataAnnotations;
|
using FreeSql.DataAnnotations;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -66,7 +66,7 @@ namespace FreeSql.Tests.MsAccessExpression
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Format()
|
public void Format()
|
||||||
{
|
{
|
||||||
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
||||||
var sql = select.WhereDynamic(item).ToSql(a => new
|
var sql = select.WhereDynamic(item).ToSql(a => new
|
||||||
{
|
{
|
||||||
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}",
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}",
|
||||||
@ -89,9 +89,9 @@ WHERE (a.[Id] = {item.Id})", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Format4()
|
public void Format4()
|
||||||
{
|
{
|
||||||
//3个 {} 时,Arguments 解析出来是分开的
|
//3个 {} 时,Arguments 解析出来是分开的
|
||||||
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
|
||||||
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
|
||||||
var sql = select.WhereDynamic(item).ToSql(a => new
|
var sql = select.WhereDynamic(item).ToSql(a => new
|
||||||
{
|
{
|
||||||
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}{a.Title}",
|
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}{a.Title}",
|
||||||
@ -249,6 +249,17 @@ WHERE (a.[Id] = {item.Id})", sql);
|
|||||||
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
//SELECT a.`Id` as1, a.`Clicks` as2, a.`TypeGuid` as3, a__Type.`Guid` as4, a__Type.`ParentId` as5, a__Type.`Name` as6, a.`Title` as7, a.`CreateTime` as8
|
||||||
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
//FROM `tb_topic` a, `TestTypeInfo` a__Type
|
||||||
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%'))
|
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%'))
|
||||||
|
|
||||||
|
var guid = Guid.NewGuid().ToString("N");
|
||||||
|
var fsql = g.msaccess;
|
||||||
|
fsql.Insert(new Topic
|
||||||
|
{
|
||||||
|
Title = $"Test{guid}Contains01"
|
||||||
|
}).ExecuteAffrows();
|
||||||
|
|
||||||
|
var ret = fsql.Select<Topic>().Where(a => a.Title.Contains(guid)).ToList();
|
||||||
|
Assert.NotEmpty(ret);
|
||||||
|
Assert.Equal($"Test{guid}Contains01", ret[0].Title);
|
||||||
}
|
}
|
||||||
[Fact]
|
[Fact]
|
||||||
public void ToLower()
|
public void ToLower()
|
||||||
@ -683,7 +694,7 @@ WHERE (a.[Id] = {item.Id})", sql);
|
|||||||
[Fact]
|
[Fact]
|
||||||
public void Replace()
|
public void Replace()
|
||||||
{
|
{
|
||||||
//System.Data.OleDb.OleDbException : 表达式中 'replace' 函数未定义。
|
//System.Data.OleDb.OleDbException : 表达式中 'replace' 函数未定义。
|
||||||
//var data = new List<object>();
|
//var data = new List<object>();
|
||||||
//data.Add(select.Where(a => a.Title.Replace("a", "b") == "aaa").ToList());
|
//data.Add(select.Where(a => a.Title.Replace("a", "b") == "aaa").ToList());
|
||||||
//data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList());
|
//data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user