Add: dynamic linq Select(+2)

This commit is contained in:
sunkaixuan
2023-10-07 03:05:59 +08:00
parent daf45f5e9e
commit f578fa3eea
3 changed files with 26 additions and 0 deletions

View File

@@ -88,6 +88,12 @@ namespace SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { expShortName, expressionString });
return this;
}
public QueryMethodInfo Where(Dictionary<string, Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expressionString)
{
var method = QueryableObj.GetType().GetMyMethod("Where", 2, typeof(Dictionary<string, Type>), typeof(FormattableString));
this.QueryableObj = method.Invoke(QueryableObj, new object[] { keyIsShortName_ValueIsType_Dictionary, expressionString });
return this;
}
public QueryMethodInfo Where(List<IConditionalModel> conditionalModels)
{
var method = QueryableObj.GetType().GetMyMethod("Where", 1, typeof(List<IConditionalModel>));
@@ -158,6 +164,13 @@ namespace SqlSugar
this.QueryableObj = method.Invoke(QueryableObj, new object[] { expShortName, expSelect, resultType });
return this;
}
public QueryMethodInfo Select(Dictionary<string, Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expSelect, Type resultType)
{
var method = QueryableObj.GetType().GetMyMethod("Select", 3, typeof(Dictionary<string, Type>), typeof(FormattableString), typeof(Type));
method = method.MakeGenericMethod(resultType);
this.QueryableObj = method.Invoke(QueryableObj, new object[] { keyIsShortName_ValueIsType_Dictionary, expSelect, resultType });
return this;
}
public QueryMethodInfo Select(string selectorSql)
{
var method = QueryableObj.GetType().GetMyMethod("Select", 1, typeof(string))

View File

@@ -926,6 +926,12 @@ namespace SqlSugar
}
return this;
}
public ISugarQueryable<T> Where(Dictionary<string, Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expressionString)
{
var exp = DynamicCoreHelper.GetWhere(keyIsShortName_ValueIsType_Dictionary, expressionString);
_Where(exp);
return this;
}
public virtual ISugarQueryable<T> Where(string expShortName, FormattableString expressionString)
{
var exp = DynamicCoreHelper.GetWhere<T>(expShortName, expressionString);
@@ -1348,6 +1354,11 @@ namespace SqlSugar
}
return _Select<TResult>(expression);
}
public ISugarQueryable<TResult> Select<TResult>(Dictionary<string, Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expSelect, Type resultType)
{
var exp = DynamicCoreHelper.GetMember(keyIsShortName_ValueIsType_Dictionary, resultType, expSelect);
return _Select<TResult>(exp);
}
public ISugarQueryable<TResult> Select<TResult>(string expShortName, FormattableString expSelect, Type resultType)
{
var exp = DynamicCoreHelper.GetMember(typeof(TResult), resultType, expShortName, expSelect);

View File

@@ -86,6 +86,7 @@ namespace SqlSugar
ISugarQueryable<T> TranLock(DbLockType? LockType = DbLockType.Wait);
ISugarQueryable<T> Where(Expression<Func<T, bool>> expression);
ISugarQueryable<T> Where(string expShortName, FormattableString expressionString);
ISugarQueryable<T> Where(Dictionary<string,Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expressionString);
ISugarQueryable<T> Where(string whereString, object parameters = null);
ISugarQueryable<T> Where(IFuncModel funcModel);
ISugarQueryable<T> Where(List<IConditionalModel> conditionalModels);
@@ -152,6 +153,7 @@ namespace SqlSugar
bool Any();
Task<bool> AnyAsync();
ISugarQueryable<TResult> Select<TResult>(string expShortName, FormattableString expSelect, Type resultType);
ISugarQueryable<TResult> Select<TResult>(Dictionary<string, Type> keyIsShortName_ValueIsType_Dictionary, FormattableString expSelect, Type resultType);
ISugarQueryable<TResult> Select<TResult>(string expShortName, FormattableString expSelect,Type EntityType, Type resultType);
ISugarQueryable<T> Select(string expShortName, FormattableString expSelect, Type resultType);
ISugarQueryable<TResult> Select<TResult>(Expression expression);