Exemplo n.º 1
0
 /// <summary>
 /// 当前实体查询上下文
 /// </summary>
 public ISearch <T> Search(string tableName = "")
 {
     if (string.IsNullOrEmpty(tableName))
     {
         tableName = TableAttribute.GetTableName <T>();
     }
     return(_db.Search <T>(tableName));
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
            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);
            }
Exemplo n.º 4
0
 public void Lock <T>(T entity) where T : Entity
 {
     Lock(TableAttribute.GetTableName(typeof(T)), entity);
 }
Exemplo n.º 5
0
 public void ForceDelete <T>(T entity) where T : Entity
 {
     ForceDelete(TableAttribute.GetTableName(typeof(T)), entity);
 }
Exemplo n.º 6
0
        public void Update <T>(T entity) where T : Entity
        {
            string tableName = TableAttribute.GetTableName(typeof(T));

            Update(tableName, entity);
        }
Exemplo n.º 7
0
        public void Insert <T>(T entity) where T : Entity
        {
            string tableName = TableAttribute.GetTableName(typeof(T));

            Insert(tableName, entity);
        }
Exemplo n.º 8
0
        public T[] SelectAll <T>(long skip, int take) where T : Entity
        {
            string tableName = TableAttribute.GetTableName(typeof(T));

            return(SelectAll <T>(tableName, skip, take));
        }
Exemplo n.º 9
0
        public T[] SelectMany <T>(params string[] keys) where T : Entity
        {
            var tableName = TableAttribute.GetTableName(typeof(T));

            return(SelectMany <T>(tableName, keys));
        }
Exemplo n.º 10
0
        public T[] SelectPrefix <T>(string prefix) where T : Entity
        {
            var tableName = TableAttribute.GetTableName(typeof(T));

            return(SelectPrefix <T>(tableName, prefix));
        }
Exemplo n.º 11
0
 public T Select <T>(string key) where T : Entity
 {
     return(Select <T>(TableAttribute.GetTableName(typeof(T)), key));
 }
Exemplo n.º 12
0
        public long Count <T>() where T : Entity
        {
            var tableName = TableAttribute.GetTableName(typeof(T));

            return(Count(tableName));
        }
Exemplo n.º 13
0
        public void Init <T>() where T : Entity
        {
            var tableName = TableAttribute.GetTableName(typeof(T));

            Init(tableName);
        }