Skip to content

Commit a35ddd3

Browse files
committed
add access like test.
1 parent 4b15cfb commit a35ddd3

File tree

1 file changed

+17
-6
lines changed
  • FreeSql.Tests/FreeSql.Tests/MsAccess/MsAccessExpression

1 file changed

+17
-6
lines changed

FreeSql.Tests/FreeSql.Tests/MsAccess/MsAccessExpression/StringTest.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using FreeSql.DataAnnotations;
1+
using FreeSql.DataAnnotations;
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
@@ -66,7 +66,7 @@ public void FirstOrDefault()
6666
[Fact]
6767
public void Format()
6868
{
69-
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
69+
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
7070
var sql = select.WhereDynamic(item).ToSql(a => new
7171
{
7272
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}",
@@ -89,9 +89,9 @@ FROM [tb_topic] a
8989
[Fact]
9090
public void Format4()
9191
{
92-
//3个 {} 时,Arguments 解析出来是分开的
93-
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
94-
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
92+
//3个 {} 时,Arguments 解析出来是分开的
93+
//4个 {} 时,Arguments[1] 只能解析这个出来,然后里面是 NewArray []
94+
var item = g.msaccess.GetRepository<Topic>().Insert(new Topic { Clicks = 101, Title = "我是中国人101", CreateTime = DateTime.Parse("2020-7-5") });
9595
var sql = select.WhereDynamic(item).ToSql(a => new
9696
{
9797
str = $"x{a.Id + 1}z-{a.CreateTime.ToString("yyyyMM")}{a.Title}{a.Title}",
@@ -249,6 +249,17 @@ public void Contains()
249249
//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
250250
//FROM `tb_topic` a, `TestTypeInfo` a__Type
251251
//WHERE((concat(a.`Title`, 'aaa')) LIKE concat('%', a__Type.`Name`, '%'))
252+
253+
var guid = Guid.NewGuid().ToString("N");
254+
var fsql = g.msaccess;
255+
fsql.Insert(new Topic
256+
{
257+
Title = $"Test{guid}Contains01"
258+
}).ExecuteAffrows();
259+
260+
var ret = fsql.Select<Topic>().Where(a => a.Title.Contains(guid)).ToList();
261+
Assert.NotEmpty(ret);
262+
Assert.Equal($"Test{guid}Contains01", ret[0].Title);
252263
}
253264
[Fact]
254265
public void ToLower()
@@ -683,7 +694,7 @@ public void TrimEnd()
683694
[Fact]
684695
public void Replace()
685696
{
686-
//System.Data.OleDb.OleDbException : 表达式中 'replace' 函数未定义。
697+
//System.Data.OleDb.OleDbException : 表达式中 'replace' 函数未定义。
687698
//var data = new List<object>();
688699
//data.Add(select.Where(a => a.Title.Replace("a", "b") == "aaa").ToList());
689700
//data.Add(select.Where(a => a.Title.Replace("a", "b").Replace("b", "c") == a.Title).ToList());

0 commit comments

Comments
 (0)