/// <summary> /// 当前实体查询上下文 /// </summary> public ISearch <T> Search(string tableName = "") { if (string.IsNullOrEmpty(tableName)) { tableName = TableAttribute.GetTableName <T>(); } return(_db.Search <T>(tableName)); }
public static string GetTableName <T>(this T t) where T : new() { Type type = t.GetType(); var properties = type.GetCustomAttributes(true); foreach (var pro in properties) { if (pro is TableAttribute) { TableAttribute tableAttribute = (TableAttribute)pro; return(tableAttribute.GetTableName()); } } return(type.Name); }
private JoinBuilder( Query <TArgs, TResult> query, JoinType joinType, string tableName, Expression joinResultBody, ParameterExpression joinResultQueryParam) { Query = query ?? throw new ArgumentNullException(nameof(query)); JoinType = joinType; JoinResultBody = joinResultBody ?? throw new ArgumentNullException(nameof(joinResultBody)); JoinResultQueryParam = joinResultQueryParam ?? throw new ArgumentNullException(nameof(joinResultQueryParam)); var joinTableType = ReflectionUtils.GetIEnumerableType(typeof(TJoin)) ?? typeof(TJoin); TableName = tableName ?? TableAttribute.GetTableName(joinTableType); }
public void Lock <T>(T entity) where T : Entity { Lock(TableAttribute.GetTableName(typeof(T)), entity); }
public void ForceDelete <T>(T entity) where T : Entity { ForceDelete(TableAttribute.GetTableName(typeof(T)), entity); }
public void Update <T>(T entity) where T : Entity { string tableName = TableAttribute.GetTableName(typeof(T)); Update(tableName, entity); }
public void Insert <T>(T entity) where T : Entity { string tableName = TableAttribute.GetTableName(typeof(T)); Insert(tableName, entity); }
public T[] SelectAll <T>(long skip, int take) where T : Entity { string tableName = TableAttribute.GetTableName(typeof(T)); return(SelectAll <T>(tableName, skip, take)); }
public T[] SelectMany <T>(params string[] keys) where T : Entity { var tableName = TableAttribute.GetTableName(typeof(T)); return(SelectMany <T>(tableName, keys)); }
public T[] SelectPrefix <T>(string prefix) where T : Entity { var tableName = TableAttribute.GetTableName(typeof(T)); return(SelectPrefix <T>(tableName, prefix)); }
public T Select <T>(string key) where T : Entity { return(Select <T>(TableAttribute.GetTableName(typeof(T)), key)); }
public long Count <T>() where T : Entity { var tableName = TableAttribute.GetTableName(typeof(T)); return(Count(tableName)); }
public void Init <T>() where T : Entity { var tableName = TableAttribute.GetTableName(typeof(T)); Init(tableName); }