mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-12-26 22:25:49 +08:00
-
This commit is contained in:
@@ -130,6 +130,10 @@ namespace OrmTest.Demo
|
||||
var isAny = db.Queryable<Student>().Where(it => it.Id == -1).Any();
|
||||
var isAny2 = db.Queryable<Student>().Any(it => it.Id == -1);
|
||||
var getListByRename = db.Queryable<School>().AS("Student").ToList();
|
||||
var in1 = db.Queryable<Student>().In(it=>it.Id,new int[] { 1, 2, 3 }).ToList();
|
||||
var in2 = db.Queryable<Student>().In(new int[] { 1, 2, 3 }).ToList();
|
||||
int[] array = new int[] { 1, 2 };
|
||||
var in3 = db.Queryable<Student>().Where(it=>NBORM.ContainsArray(array, it.Id)).ToList();
|
||||
var group = db.Queryable<Student>().GroupBy(it => it.Id)
|
||||
.Having(it => NBORM.AggregateCount(it.Id) > 10)
|
||||
.Select(it => new { id = NBORM.AggregateCount(it.Id) }).ToList();
|
||||
|
||||
@@ -141,7 +141,7 @@ namespace SqlSugar
|
||||
return this;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> In(params object[] pkValues)
|
||||
public ISugarQueryable<T> In<TParamter>(params TParamter[] pkValues)
|
||||
{
|
||||
if (pkValues == null || pkValues.Length == 0)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@@ -39,12 +40,20 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual string ContainsArray(MethodCallExpressionModel model)
|
||||
{
|
||||
var inValues = (object[])model.Args[0].MemberValue;
|
||||
var inValueIEnumerable = (IEnumerable)model.Args[0].MemberValue;
|
||||
List<object> inValues = new List<object>();
|
||||
if (inValueIEnumerable != null)
|
||||
{
|
||||
foreach (var item in inValueIEnumerable)
|
||||
{
|
||||
inValues.Add(item);
|
||||
}
|
||||
}
|
||||
var value = model.Args[1].MemberName;
|
||||
string inValueString = null;
|
||||
if (inValues != null && inValues.Length > 0)
|
||||
if (inValues != null && inValues.Count > 0)
|
||||
{
|
||||
inValueString = inValues.ToJoinSqlInVals();
|
||||
inValueString = inValues.ToArray().ToJoinSqlInVals();
|
||||
}
|
||||
else {
|
||||
return " (1=2) ";
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace SqlSugar
|
||||
public static string ToUpper(object thisValue) { throw new NotImplementedException(); }
|
||||
public static string Trim(object thisValue) { throw new NotImplementedException(); }
|
||||
public static bool Contains(string thisValue, string parameterValue) { throw new NotImplementedException();}
|
||||
public static bool ContainsArray(object [] thisValue, string parameterValue) { throw new NotImplementedException(); }
|
||||
public static bool ContainsArray<T>(T [] thisValue, object parameterValue) { throw new NotImplementedException(); }
|
||||
public static bool StartsWith(object thisValue, string parameterValue) { throw new NotImplementedException(); }
|
||||
public static bool EndsWith(object thisValue, string parameterValue) { throw new NotImplementedException(); }
|
||||
public new static bool Equals(object thisValue, object parameterValue) { throw new NotImplementedException(); }
|
||||
|
||||
@@ -80,7 +80,8 @@ namespace SqlSugar
|
||||
IsMember = parameter.ChildExpression is MemberExpression,
|
||||
MemberName = parameter.CommonTempData
|
||||
};
|
||||
if (methodCallExpressionArgs.IsMember && parameter.ChildExpression != null && parameter.ChildExpression.ToString() == "DateTime.Now") {
|
||||
if (methodCallExpressionArgs.IsMember && parameter.ChildExpression != null && parameter.ChildExpression.ToString() == "DateTime.Now")
|
||||
{
|
||||
methodCallExpressionArgs.IsMember = false;
|
||||
}
|
||||
var value = methodCallExpressionArgs.MemberName;
|
||||
@@ -119,9 +120,11 @@ namespace SqlSugar
|
||||
case "Trim":
|
||||
return this.Context.DbMehtods.Trim(model);
|
||||
case "Contains":
|
||||
return this.Context.DbMehtods.Contains(model);
|
||||
return this.Context.DbMehtods.Contains(model);
|
||||
case "ContainsArray":
|
||||
return this.Context.DbMehtods.ContainsArray(model);
|
||||
var result = this.Context.DbMehtods.ContainsArray(model);
|
||||
this.Context.Parameters.RemoveAll(it => it.ParameterName == model.Args[0].MemberName.ObjToString());
|
||||
return result;
|
||||
case "Equals":
|
||||
return this.Context.DbMehtods.Equals(model);
|
||||
case "DateIsSame":
|
||||
@@ -143,7 +146,7 @@ namespace SqlSugar
|
||||
case "EndsWith":
|
||||
return this.Context.DbMehtods.EndsWith(model);
|
||||
case "ToInt32":
|
||||
return this.Context.DbMehtods.ToInt32(model);
|
||||
return this.Context.DbMehtods.ToInt32(model);
|
||||
case "ToInt64":
|
||||
return this.Context.DbMehtods.ToInt64(model);
|
||||
case "ToDate":
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace SqlSugar
|
||||
//ISugarQueryable<T> WhereIF<T2, T3, T4>(bool isWhere, Expression<Func<T2, T3, T4, bool>> expression);
|
||||
//ISugarQueryable<T> WhereIF<T2, T3, T4, T5>(bool isWhere, Expression<Func<T2, T3, T4, T5, bool>> expression);
|
||||
//ISugarQueryable<T> WhereIF<T2, T3, T4, T5, T6>(bool isWhere, Expression<Func<T2, T3, T4, T5, T6, bool>> expression);
|
||||
ISugarQueryable<T> In(params object[] pkValues);
|
||||
ISugarQueryable<T> In<TParamter>(params TParamter[] pkValues);
|
||||
|
||||
T InSingle(object pkValue);
|
||||
ISugarQueryable<T> In<FieldType>(string InFieldName, params FieldType[] inValues);
|
||||
|
||||
Reference in New Issue
Block a user