mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-04-22 18:52:50 +08:00
## v0.12.11 调整 ContainsMany 方法名为 Contains
This commit is contained in:
parent
d186affe73
commit
dee1d9af8b
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>BaseEntity 是一种极简单的 CodeFirst 开发方式,特别对单表或多表CRUD,利用继承节省了每个实体类的重复属性(创建时间、ID等字段),软件删除等功能,进行 crud 操作时不必时常考虑仓储的使用.</Description>
|
<Description>BaseEntity 是一种极简单的 CodeFirst 开发方式,特别对单表或多表CRUD,利用继承节省了每个实体类的重复属性(创建时间、ID等字段),软件删除等功能,进行 crud 操作时不必时常考虑仓储的使用.</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 扩展包,可实现实体类属性为对象时,以JSON形式映射存储.</Description>
|
<Description>FreeSql 扩展包,可实现实体类属性为对象时,以JSON形式映射存储.</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>
|
<Description>FreeSql 扩展包,可实现【延时加载】属性.</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>
|
<Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>
|
||||||
|
@ -110,13 +110,6 @@
|
|||||||
清空状态数据
|
清空状态数据
|
||||||
</summary>
|
</summary>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
|
|
||||||
<summary>
|
|
||||||
根据 lambda 条件删除数据
|
|
||||||
</summary>
|
|
||||||
<param name="predicate"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
<member name="M:FreeSql.DbSet`1.Add(`0)">
|
||||||
<summary>
|
<summary>
|
||||||
添加
|
添加
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
<Description>FreeSql Implementation of General Repository, Support MySql/SqlServer/PostgreSQL/Oracle/Sqlite, and read/write separation、and split table.</Description>
|
||||||
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/2881099/FreeSql/wiki/Repository</PackageProjectUrl>
|
||||||
|
@ -264,13 +264,34 @@ namespace FreeSql.Tests
|
|||||||
});
|
});
|
||||||
|
|
||||||
List<(Guid, DateTime)> contains2linqarr = new List<(Guid, DateTime)>();
|
List<(Guid, DateTime)> contains2linqarr = new List<(Guid, DateTime)>();
|
||||||
Assert.Equal("SELECT 1 as1 FROM \"TestIgnoreDefaultValue\" a WHERE (1=0)", g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains2linqarr.ContainsMany(a.Id, a.ct1)).ToSql(a => 1).Replace("\r\n", ""));
|
Assert.Equal("SELECT 1 as1 FROM \"TestIgnoreDefaultValue\" a WHERE (1=0)", g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains2linqarr.Contains(a.Id, a.ct1)).ToSql(a => 1).Replace("\r\n", ""));
|
||||||
g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains2linqarr.ContainsMany(a.Id, a.ct1)).ToList();
|
g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains2linqarr.Contains(a.Id, a.ct1)).ToList();
|
||||||
|
|
||||||
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
||||||
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
||||||
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
contains2linqarr.Add((Guid.NewGuid(), DateTime.Now));
|
||||||
g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains2linqarr.ContainsMany(a.Id, a.ct1)).ToList();
|
g.sqlite.Select<TestIgnoreDefaultValue>()
|
||||||
|
.Where(a => contains2linqarr.Contains(a.Id, a.ct1)).ToList();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<(Guid, DateTime, DateTime?)> contains3linqarr = new List<(Guid, DateTime, DateTime?)>();
|
||||||
|
Assert.Equal("SELECT 1 as1 FROM \"TestIgnoreDefaultValue\" a WHERE (1=0)", g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains3linqarr.Contains(a.Id, a.ct1, a.ct2)).ToSql(a => 1).Replace("\r\n", ""));
|
||||||
|
g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains3linqarr.Contains(a.Id, a.ct1, a.ct2)).ToList();
|
||||||
|
|
||||||
|
contains3linqarr.Add((Guid.NewGuid(), DateTime.Now, DateTime.Now));
|
||||||
|
contains3linqarr.Add((Guid.NewGuid(), DateTime.Now, DateTime.Now));
|
||||||
|
contains3linqarr.Add((Guid.NewGuid(), DateTime.Now, DateTime.Now));
|
||||||
|
g.sqlite.Select<TestIgnoreDefaultValue>().Where(a => contains3linqarr.Contains(a.Id, a.ct1, a.ct2)).ToList();
|
||||||
|
|
||||||
var start = DateTime.Now.Date;
|
var start = DateTime.Now.Date;
|
||||||
var end = DateTime.Now.AddDays(1).Date.AddMilliseconds(-1);
|
var end = DateTime.Now.AddDays(1).Date.AddMilliseconds(-1);
|
||||||
|
130
FreeSql/Extensions/FreeSqlGlobalExpressionCall.cs
Normal file
130
FreeSql/Extensions/FreeSqlGlobalExpressionCall.cs
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
using FreeSql;
|
||||||
|
using FreeSql.DataAnnotations;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
|
[ExpressionCall]
|
||||||
|
public static class FreeSqlGlobalExpressionCall
|
||||||
|
{
|
||||||
|
public static ThreadLocal<ExpressionCallContext> expContext = new ThreadLocal<ExpressionCallContext>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C#: that >= between && that <= and<para></para>
|
||||||
|
/// SQL: that BETWEEN between AND and
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <param name="between"></param>
|
||||||
|
/// <param name="and"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Between(this DateTime that, DateTime between, DateTime and)
|
||||||
|
{
|
||||||
|
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||||
|
return that >= between && that <= and;
|
||||||
|
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} between {expContext.Value.ParsedContent["between"]} and {expContext.Value.ParsedContent["and"]}";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 注意:这个方法和 Between 有细微区别<para></para>
|
||||||
|
/// C#: that >= start && that < end<para></para>
|
||||||
|
/// SQL: that >= start and that < end
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <param name="start"></param>
|
||||||
|
/// <param name="end"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool BetweenEnd(this DateTime that, DateTime start, DateTime end)
|
||||||
|
{
|
||||||
|
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||||
|
return that >= start && that < end;
|
||||||
|
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} >= {expContext.Value.ParsedContent["start"]} and {expContext.Value.ParsedContent["that"]} < {expContext.Value.ParsedContent["end"]}";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
||||||
|
/// SQL: <para></para>
|
||||||
|
/// exp1 = that[0].Item1 and exp2 = that[0].Item2 OR <para></para>
|
||||||
|
/// exp1 = that[1].Item1 and exp2 = that[1].Item2 OR <para></para>
|
||||||
|
/// ... <para></para>
|
||||||
|
/// 注意:当 that 为 null 或 empty 时,返回 1=0
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T1"></typeparam>
|
||||||
|
/// <typeparam name="T2"></typeparam>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <param name="exp1"></param>
|
||||||
|
/// <param name="exp2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Contains<T1, T2>([RawValue] this IEnumerable<(T1, T2)> that, T1 exp1, T2 exp2)
|
||||||
|
{
|
||||||
|
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||||
|
return that?.Any(a => a.Item1.Equals(exp1) && a.Item2.Equals(exp2)) == true;
|
||||||
|
if (that?.Any() != true)
|
||||||
|
{
|
||||||
|
expContext.Value.Result = "1=0";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
var idx = 0;
|
||||||
|
foreach (var item in that)
|
||||||
|
{
|
||||||
|
if (idx++ > 0) sb.Append(" OR \r\n");
|
||||||
|
sb
|
||||||
|
.Append(expContext.Value.ParsedContent["exp1"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T1), item.Item1)))
|
||||||
|
.Append(" AND ")
|
||||||
|
.Append(expContext.Value.ParsedContent["exp2"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T2), item.Item2)));
|
||||||
|
}
|
||||||
|
expContext.Value.Result = sb.ToString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// C#:从元组集合中查找 exp1, exp2, exp2 是否存在<para></para>
|
||||||
|
/// SQL: <para></para>
|
||||||
|
/// exp1 = that[0].Item1 and exp2 = that[0].Item2 and exp3 = that[0].Item3 OR <para></para>
|
||||||
|
/// exp1 = that[1].Item1 and exp2 = that[1].Item2 and exp3 = that[1].Item3 OR <para></para>
|
||||||
|
/// ... <para></para>
|
||||||
|
/// 注意:当 that 为 null 或 empty 时,返回 1=0
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T1"></typeparam>
|
||||||
|
/// <typeparam name="T2"></typeparam>
|
||||||
|
/// <typeparam name="T3"></typeparam>
|
||||||
|
/// <param name="that"></param>
|
||||||
|
/// <param name="exp1"></param>
|
||||||
|
/// <param name="exp2"></param>
|
||||||
|
/// <param name="exp3"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Contains<T1, T2, T3>([RawValue] this IEnumerable<(T1, T2, T3)> that, T1 exp1, T2 exp2, T3 exp3)
|
||||||
|
{
|
||||||
|
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
||||||
|
return that.Any(a => a.Item1.Equals(exp1) && a.Item2.Equals(exp2) && a.Item3.Equals(exp3));
|
||||||
|
if (that.Any() == false)
|
||||||
|
{
|
||||||
|
expContext.Value.Result = "1=0";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
var idx = 0;
|
||||||
|
foreach (var item in that)
|
||||||
|
{
|
||||||
|
if (idx++ > 0) sb.Append(" OR \r\n");
|
||||||
|
sb
|
||||||
|
.Append(expContext.Value.ParsedContent["exp1"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T1), item.Item1)))
|
||||||
|
.Append(" AND ")
|
||||||
|
.Append(expContext.Value.ParsedContent["exp2"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T2), item.Item2)))
|
||||||
|
.Append(" AND ")
|
||||||
|
.Append(expContext.Value.ParsedContent["exp3"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T3), item.Item3)));
|
||||||
|
}
|
||||||
|
expContext.Value.Result = sb.ToString();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -222,124 +222,4 @@ public static partial class FreeSqlGlobalExtensions
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region LambdaExpression
|
|
||||||
|
|
||||||
public static ThreadLocal<ExpressionCallContext> expContext = new ThreadLocal<ExpressionCallContext>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// C#: that >= between && that <= and<para></para>
|
|
||||||
/// SQL: that BETWEEN between AND and
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="between"></param>
|
|
||||||
/// <param name="and"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ExpressionCall]
|
|
||||||
public static bool Between(this DateTime that, DateTime between, DateTime and)
|
|
||||||
{
|
|
||||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
|
||||||
return that >= between && that <= and;
|
|
||||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} between {expContext.Value.ParsedContent["between"]} and {expContext.Value.ParsedContent["and"]}";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 注意:这个方法和 Between 有细微区别<para></para>
|
|
||||||
/// C#: that >= start && that < end<para></para>
|
|
||||||
/// SQL: that >= start and that < end
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="start"></param>
|
|
||||||
/// <param name="end"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ExpressionCall]
|
|
||||||
public static bool BetweenEnd(this DateTime that, DateTime start, DateTime end)
|
|
||||||
{
|
|
||||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
|
||||||
return that >= start && that < end;
|
|
||||||
expContext.Value.Result = $"{expContext.Value.ParsedContent["that"]} >= {expContext.Value.ParsedContent["start"]} and {expContext.Value.ParsedContent["that"]} < {expContext.Value.ParsedContent["end"]}";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
|
||||||
/// SQL: <para></para>
|
|
||||||
/// exp1 = that[0].Item1 and exp2 = that[0].Item2 OR <para></para>
|
|
||||||
/// exp1 = that[1].Item1 and exp2 = that[1].Item2 OR <para></para>
|
|
||||||
/// ... <para></para>
|
|
||||||
/// 注意:当 that 为 null 或 empty 时,返回 1=0
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T1"></typeparam>
|
|
||||||
/// <typeparam name="T2"></typeparam>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="exp1"></param>
|
|
||||||
/// <param name="exp2"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ExpressionCall]
|
|
||||||
public static bool ContainsMany<T1, T2>([RawValue] this IEnumerable<(T1, T2)> that, T1 exp1, T2 exp2)
|
|
||||||
{
|
|
||||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
|
||||||
return that?.Any(a => a.Item1.Equals(exp1) && a.Item2.Equals(exp2)) == true;
|
|
||||||
if (that?.Any() != true)
|
|
||||||
{
|
|
||||||
expContext.Value.Result = "1=0";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
var idx = 0;
|
|
||||||
foreach (var item in that)
|
|
||||||
{
|
|
||||||
if (idx++ > 0) sb.Append(" OR \r\n");
|
|
||||||
sb
|
|
||||||
.Append(expContext.Value.ParsedContent["exp1"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T1), item.Item1)))
|
|
||||||
.Append(" AND ")
|
|
||||||
.Append(expContext.Value.ParsedContent["exp2"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T2), item.Item2)));
|
|
||||||
}
|
|
||||||
expContext.Value.Result = sb.ToString();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
|
||||||
/// SQL: <para></para>
|
|
||||||
/// exp1 = that[0].Item1 and exp2 = that[0].Item2 and exp3 = that[0].Item3 OR <para></para>
|
|
||||||
/// exp1 = that[1].Item1 and exp2 = that[1].Item2 and exp3 = that[1].Item3 OR <para></para>
|
|
||||||
/// ... <para></para>
|
|
||||||
/// 注意:当 that 为 null 或 empty 时,返回 1=0
|
|
||||||
/// </summary>
|
|
||||||
/// <typeparam name="T1"></typeparam>
|
|
||||||
/// <typeparam name="T2"></typeparam>
|
|
||||||
/// <typeparam name="T3"></typeparam>
|
|
||||||
/// <param name="that"></param>
|
|
||||||
/// <param name="exp1"></param>
|
|
||||||
/// <param name="exp2"></param>
|
|
||||||
/// <param name="exp3"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
[ExpressionCall]
|
|
||||||
public static bool ContainsMany<T1, T2, T3>([RawValue] this IEnumerable<(T1, T2, T3)> that, T1 exp1, T2 exp2, T3 exp3)
|
|
||||||
{
|
|
||||||
if (expContext.IsValueCreated == false || expContext.Value == null || expContext.Value.ParsedContent == null)
|
|
||||||
return that.Any(a => a.Item1.Equals(exp1) && a.Item2.Equals(exp2) && a.Item3.Equals(exp3));
|
|
||||||
if (that.Any() == false)
|
|
||||||
{
|
|
||||||
expContext.Value.Result = "1=0";
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
var idx = 0;
|
|
||||||
foreach (var item in that)
|
|
||||||
{
|
|
||||||
if (idx++ > 0) sb.Append(" OR \r\n");
|
|
||||||
sb
|
|
||||||
.Append(expContext.Value.ParsedContent["exp1"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T1), item.Item1)))
|
|
||||||
.Append(" AND ")
|
|
||||||
.Append(expContext.Value.ParsedContent["exp2"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T2), item.Item2)))
|
|
||||||
.Append(" AND ")
|
|
||||||
.Append(expContext.Value.ParsedContent["exp3"]).Append(" = ").Append(expContext.Value.FormatSql(FreeSql.Internal.Utils.GetDataReaderValue(typeof(T3), item.Item3)));
|
|
||||||
}
|
|
||||||
expContext.Value.Result = sb.ToString();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>
|
<Description>FreeSql is the most convenient ORM in .NetCore, .NetFramework, And Xamarin. It supports Mysql, Postgresql, SqlServer, Oracle, Sqlite, And Odbc.</Description>
|
||||||
|
@ -2688,6 +2688,61 @@
|
|||||||
<param name="str"></param>
|
<param name="str"></param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExpressionCall.Between(System.DateTime,System.DateTime,System.DateTime)">
|
||||||
|
<summary>
|
||||||
|
C#: that >= between && that <= and<para></para>
|
||||||
|
SQL: that BETWEEN between AND and
|
||||||
|
</summary>
|
||||||
|
<param name="that"></param>
|
||||||
|
<param name="between"></param>
|
||||||
|
<param name="and"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExpressionCall.BetweenEnd(System.DateTime,System.DateTime,System.DateTime)">
|
||||||
|
<summary>
|
||||||
|
注意:这个方法和 Between 有细微区别<para></para>
|
||||||
|
C#: that >= start && that < end<para></para>
|
||||||
|
SQL: that >= start and that < end
|
||||||
|
</summary>
|
||||||
|
<param name="that"></param>
|
||||||
|
<param name="start"></param>
|
||||||
|
<param name="end"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExpressionCall.Contains``2(System.Collections.Generic.IEnumerable{System.ValueTuple{``0,``1}},``0,``1)">
|
||||||
|
<summary>
|
||||||
|
C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
||||||
|
SQL: <para></para>
|
||||||
|
exp1 = that[0].Item1 and exp2 = that[0].Item2 OR <para></para>
|
||||||
|
exp1 = that[1].Item1 and exp2 = that[1].Item2 OR <para></para>
|
||||||
|
... <para></para>
|
||||||
|
注意:当 that 为 null 或 empty 时,返回 1=0
|
||||||
|
</summary>
|
||||||
|
<typeparam name="T1"></typeparam>
|
||||||
|
<typeparam name="T2"></typeparam>
|
||||||
|
<param name="that"></param>
|
||||||
|
<param name="exp1"></param>
|
||||||
|
<param name="exp2"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
|
<member name="M:FreeSqlGlobalExpressionCall.Contains``3(System.Collections.Generic.IEnumerable{System.ValueTuple{``0,``1,``2}},``0,``1,``2)">
|
||||||
|
<summary>
|
||||||
|
C#:从元组集合中查找 exp1, exp2, exp2 是否存在<para></para>
|
||||||
|
SQL: <para></para>
|
||||||
|
exp1 = that[0].Item1 and exp2 = that[0].Item2 and exp3 = that[0].Item3 OR <para></para>
|
||||||
|
exp1 = that[1].Item1 and exp2 = that[1].Item2 and exp3 = that[1].Item3 OR <para></para>
|
||||||
|
... <para></para>
|
||||||
|
注意:当 that 为 null 或 empty 时,返回 1=0
|
||||||
|
</summary>
|
||||||
|
<typeparam name="T1"></typeparam>
|
||||||
|
<typeparam name="T2"></typeparam>
|
||||||
|
<typeparam name="T3"></typeparam>
|
||||||
|
<param name="that"></param>
|
||||||
|
<param name="exp1"></param>
|
||||||
|
<param name="exp2"></param>
|
||||||
|
<param name="exp3"></param>
|
||||||
|
<returns></returns>
|
||||||
|
</member>
|
||||||
<member name="M:FreeSqlGlobalExtensions.Distance(System.Drawing.Point,System.Drawing.Point)">
|
<member name="M:FreeSqlGlobalExtensions.Distance(System.Drawing.Point,System.Drawing.Point)">
|
||||||
<summary>
|
<summary>
|
||||||
测量两个经纬度的距离,返回单位:米
|
测量两个经纬度的距离,返回单位:米
|
||||||
@ -2773,61 +2828,6 @@
|
|||||||
<param name="then">即能 ThenInclude,还可以二次过滤(这个 EFCore 做不到?)</param>
|
<param name="then">即能 ThenInclude,还可以二次过滤(这个 EFCore 做不到?)</param>
|
||||||
<returns></returns>
|
<returns></returns>
|
||||||
</member>
|
</member>
|
||||||
<member name="M:FreeSqlGlobalExtensions.Between(System.DateTime,System.DateTime,System.DateTime)">
|
|
||||||
<summary>
|
|
||||||
C#: that >= between && that <= and<para></para>
|
|
||||||
SQL: that BETWEEN between AND and
|
|
||||||
</summary>
|
|
||||||
<param name="that"></param>
|
|
||||||
<param name="between"></param>
|
|
||||||
<param name="and"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSqlGlobalExtensions.BetweenEnd(System.DateTime,System.DateTime,System.DateTime)">
|
|
||||||
<summary>
|
|
||||||
注意:这个方法和 Between 有细微区别<para></para>
|
|
||||||
C#: that >= start && that < end<para></para>
|
|
||||||
SQL: that >= start and that < end
|
|
||||||
</summary>
|
|
||||||
<param name="that"></param>
|
|
||||||
<param name="start"></param>
|
|
||||||
<param name="end"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSqlGlobalExtensions.ContainsMany``2(System.Collections.Generic.IEnumerable{System.ValueTuple{``0,``1}},``0,``1)">
|
|
||||||
<summary>
|
|
||||||
C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
|
||||||
SQL: <para></para>
|
|
||||||
exp1 = that[0].Item1 and exp2 = that[0].Item2 OR <para></para>
|
|
||||||
exp1 = that[1].Item1 and exp2 = that[1].Item2 OR <para></para>
|
|
||||||
... <para></para>
|
|
||||||
注意:当 that 为 null 或 empty 时,返回 1=0
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T1"></typeparam>
|
|
||||||
<typeparam name="T2"></typeparam>
|
|
||||||
<param name="that"></param>
|
|
||||||
<param name="exp1"></param>
|
|
||||||
<param name="exp2"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:FreeSqlGlobalExtensions.ContainsMany``3(System.Collections.Generic.IEnumerable{System.ValueTuple{``0,``1,``2}},``0,``1,``2)">
|
|
||||||
<summary>
|
|
||||||
C#:从元组集合中查找 exp1, exp2 是否存在<para></para>
|
|
||||||
SQL: <para></para>
|
|
||||||
exp1 = that[0].Item1 and exp2 = that[0].Item2 and exp3 = that[0].Item3 OR <para></para>
|
|
||||||
exp1 = that[1].Item1 and exp2 = that[1].Item2 and exp3 = that[1].Item3 OR <para></para>
|
|
||||||
... <para></para>
|
|
||||||
注意:当 that 为 null 或 empty 时,返回 1=0
|
|
||||||
</summary>
|
|
||||||
<typeparam name="T1"></typeparam>
|
|
||||||
<typeparam name="T2"></typeparam>
|
|
||||||
<typeparam name="T3"></typeparam>
|
|
||||||
<param name="that"></param>
|
|
||||||
<param name="exp1"></param>
|
|
||||||
<param name="exp2"></param>
|
|
||||||
<param name="exp3"></param>
|
|
||||||
<returns></returns>
|
|
||||||
</member>
|
|
||||||
<member name="M:System.Linq.Expressions.LambadaExpressionExtensions.And``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
<member name="M:System.Linq.Expressions.LambadaExpressionExtensions.And``1(System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}},System.Linq.Expressions.Expression{System.Func{``0,System.Boolean}})">
|
||||||
<summary>
|
<summary>
|
||||||
使用 and 拼接两个 lambda 表达式
|
使用 and 拼接两个 lambda 表达式
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net452;net451;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
<Description>FreeSql 数据库实现,基于 MySql 5.6</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库 Odbc 实现,基于 {Oracle}、{SQL Server}、{MySQL ODBC 8.0 Unicode Driver}、{PostgreSQL Unicode(x64)} 专用访问实现,以及通用 Odbc 访问所有数据库</Description>
|
<Description>FreeSql 数据库 Odbc 实现,基于 {Oracle}、{SQL Server}、{MySQL ODBC 8.0 Unicode Driver}、{PostgreSQL Unicode(x64)} 专用访问实现,以及通用 Odbc 访问所有数据库</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 Oracle 11</Description>
|
<Description>FreeSql 数据库实现,基于 Oracle 11</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net461;net452;net451;net45</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>
|
<Description>FreeSql 数据库实现,基于 PostgreSQL 9.5</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net451;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net451;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
<Description>FreeSql 数据库实现,基于 SqlServer 2005+,并根据版本适配分页方法:row_number 或 offset fetch next</Description>
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
<TargetFrameworks>netstandard2.0;net45;net40</TargetFrameworks>
|
||||||
<Version>0.12.10</Version>
|
<Version>0.12.11</Version>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<Authors>YeXiangQin</Authors>
|
<Authors>YeXiangQin</Authors>
|
||||||
<Description>FreeSql 数据库实现,基于 Sqlite 3.0,支持 .NetCore、.NetFramework、Xamarin</Description>
|
<Description>FreeSql 数据库实现,基于 Sqlite 3.0,支持 .NetCore、.NetFramework、Xamarin</Description>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user