mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-03 04:13:48 +08:00
Synchronization code
This commit is contained in:
parent
e0a6a00e76
commit
c7f099b7c6
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@ -15,11 +16,81 @@ namespace SqlSugar
|
||||
_Includes<T, TReturn1,TReturn2>(this.Context, include1,include2);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> IncludesByExpression3<TReturn1, TReturn2, TReturn3>(Expression include1, Expression include2, Expression include3)
|
||||
{
|
||||
_Includes<T, TReturn1, TReturn2, TReturn3>(this.Context, include1, include2, include3);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> IncludesByExpression<TReturn1>(Expression include1)
|
||||
{
|
||||
_Includes<T, TReturn1>(this.Context, include1);
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2)
|
||||
{
|
||||
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression2")
|
||||
.First();
|
||||
List<Expression> parametres = new List<Expression>();
|
||||
List<Type> types = new List<Type>();
|
||||
var entityInfo = this.EntityInfo;
|
||||
method = GetIncludesByNameStringMethod(types,navMemberName, method, parametres, entityInfo);
|
||||
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
|
||||
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||
method = GetIncludesByNameStringMethod(types,thenNavMemberName2, method, parametres, entityInfo2);
|
||||
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
|
||||
return this;
|
||||
}
|
||||
public ISugarQueryable<T> IncludesByNameString(string navMemberName, string thenNavMemberName2,string thenNavMemberName3)
|
||||
{
|
||||
var method = this.GetType().GetMethods().Where(it => it.Name == "IncludesByExpression3")
|
||||
.First();
|
||||
List<Expression> parametres = new List<Expression>();
|
||||
List<Type> types = new List<Type>();
|
||||
var entityInfo = this.EntityInfo;
|
||||
method = GetIncludesByNameStringMethod(types, navMemberName, method, parametres, entityInfo);
|
||||
//var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
|
||||
var entityInfo2 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||
method = GetIncludesByNameStringMethod(types, thenNavMemberName2, method, parametres, entityInfo2);
|
||||
var entityInfo3 = this.Context.EntityMaintenance.GetEntityInfo(types.Last());
|
||||
method = GetIncludesByNameStringMethod(types, thenNavMemberName3, method, parametres, entityInfo3);
|
||||
method.MakeGenericMethod(types.ToArray()).Invoke(this, parametres.Cast<object>().ToArray());
|
||||
return this;
|
||||
}
|
||||
|
||||
private static MethodInfo GetIncludesByNameStringMethod(List<Type> types,string navMemberName, MethodInfo method, List<Expression> parametres, EntityInfo entityInfo)
|
||||
{
|
||||
var navFirst = GetNavColumnInfo(navMemberName, entityInfo);
|
||||
parametres.AddRange(GetIncludesByNameStringParameters(entityInfo.Type, navFirst));
|
||||
if (navFirst.PropertyInfo.PropertyType.FullName.IsCollectionsList())
|
||||
{
|
||||
types.Add(navFirst.PropertyInfo.PropertyType.GetGenericArguments()[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
types.Add(navFirst.PropertyInfo.PropertyType);
|
||||
}
|
||||
return method;
|
||||
}
|
||||
|
||||
private static EntityColumnInfo GetNavColumnInfo(string navMemberName, EntityInfo entityInfo)
|
||||
{
|
||||
return entityInfo.Columns.Where(it => it.Navigat != null && it.PropertyName.EqualCase(navMemberName)).FirstOrDefault();
|
||||
}
|
||||
|
||||
private static List<Expression> GetIncludesByNameStringParameters(Type type,EntityColumnInfo item)
|
||||
{
|
||||
var parametres = new List<Expression> { };
|
||||
var properyType = item.PropertyInfo.PropertyType;
|
||||
var properyItemType = properyType;
|
||||
if (properyType.FullName.IsCollectionsList())
|
||||
{
|
||||
properyItemType = properyType.GetGenericArguments()[0];
|
||||
}
|
||||
var exp = ExpressionBuilderHelper.CreateExpressionSelectField(type, item.PropertyName, properyType);
|
||||
parametres.Add(exp);
|
||||
return parametres;
|
||||
}
|
||||
|
||||
public ISugarQueryable<T> IncludesByNameString(string navMemberName)
|
||||
{
|
||||
var navs = this.EntityInfo.Columns.Where(it => it.Navigat != null&&it.PropertyName.EqualCase(navMemberName)).ToList();
|
||||
|
@ -178,6 +178,18 @@ namespace SqlSugar
|
||||
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName });
|
||||
return this;
|
||||
}
|
||||
public QueryMethodInfo Includes(string navProperyName,string thenNavProperyName2)
|
||||
{
|
||||
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 2, typeof(string),typeof(string));
|
||||
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName , thenNavProperyName2 });
|
||||
return this;
|
||||
}
|
||||
public QueryMethodInfo Includes(string navProperyName, string thenNavProperyName2, string thenNavProperyName3)
|
||||
{
|
||||
var method = QueryableObj.GetType().GetMyMethod("IncludesByNameString", 3, typeof(string), typeof(string),typeof(string));
|
||||
this.QueryableObj = method.Invoke(QueryableObj, new object[] { navProperyName, thenNavProperyName2 , thenNavProperyName3 });
|
||||
return this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Result
|
||||
|
@ -17,6 +17,7 @@ namespace SqlSugar
|
||||
ISugarQueryable<T> IncludesByExpression2<TReturn1, TReturn2>(Expression include1, Expression include2);
|
||||
ISugarQueryable<T> IncludesByExpression<TReturn1>(Expression include1);
|
||||
ISugarQueryable<T> IncludesByNameString(string navMemberName);
|
||||
ISugarQueryable<T> IncludesByNameString(string navMemberName,string thenNavMemberName2);
|
||||
ISugarQueryable<T> IncludesAllFirstLayer(params string[] ignoreProperyNameList);
|
||||
ISugarQueryable<T> IncludesAllSecondLayer<TReturn1>(Expression<Func<T, TReturn1>> expression,params string[] ignoreProperyNameList);
|
||||
ISugarQueryable<T> Includes<TReturn1>(Expression<Func<T, List<TReturn1>>> include1);
|
||||
|
@ -113,6 +113,7 @@ namespace SqlSugar
|
||||
new KeyValuePair<string, CSharpDataType>("rowid",CSharpDataType.@string),
|
||||
|
||||
new KeyValuePair<string, CSharpDataType>("date",CSharpDataType.DateTime),
|
||||
new KeyValuePair<string, CSharpDataType>("timestamptz",CSharpDataType.DateTime),
|
||||
new KeyValuePair<string, CSharpDataType>("timestamp",CSharpDataType.DateTime),
|
||||
new KeyValuePair<string, CSharpDataType>("timestamp with local time zone",CSharpDataType.DateTime),
|
||||
new KeyValuePair<string, CSharpDataType>("timestamp with time zone",CSharpDataType.DateTime),
|
||||
|
@ -33,6 +33,10 @@ namespace SqlSugar
|
||||
}
|
||||
public override string GetTranslationColumnName(string columnName)
|
||||
{
|
||||
if (columnName == "systimestamp")
|
||||
{
|
||||
return columnName;
|
||||
}
|
||||
if (columnName.Contains(":"))
|
||||
return base.GetTranslationColumnName(columnName);
|
||||
else if (columnName.Contains("\".\""))
|
||||
|
Loading…
Reference in New Issue
Block a user