Esempio n. 1
0
        private IList <T> QueryItems <T>(string column, object param, DataTable table, string[] conditions, string orderBy, bool activeOnly) where T : class, IDbQuery, new()
        {
            var dbEntity  = DbEntityCache.GetDbEntity <T>();
            var fields    = param == null ? new ColumnField[] { } : ColumnField.GetFields(param);
            var tableName = WriteToServer(table);
            var sql       = CommandTextCache.GetSplitQueryCommandText(tableName, column, dbEntity, fields, conditions, orderBy, activeOnly);

            return(conn.Query <T>(sql, param, tran, true, null, CommandType.Text).ToList());
        }
Esempio n. 2
0
        private IList <T> QueryItems <T>(string key, object param, string[] conditions, string orderBy, bool activeOnly) where T : class, IDbQuery, new()
        {
            var sql = CommandTextCache.GetCachedCommandText(key);

            if (string.IsNullOrEmpty(sql))
            {
                var dbEntity = DbEntityCache.GetDbEntity <T>();
                var fields   = param == null ? new ColumnField[] { } : ColumnField.GetFields(param);
                sql = CommandTextCache.GetMultiQueryCommandText(key, dbEntity, fields, conditions, orderBy, activeOnly);
            }

            return(conn.Query <T>(sql, param, tran, true, null, CommandType.Text).ToList());
        }
Esempio n. 3
0
        public void Update <T>(T item) where T : class, IDbEntity, IDbModel, new()
        {
            ThrowIfNull(item);

            var key = string.Format("{0}.Update", typeof(T));
            var sql = CommandTextCache.GetCachedCommandText(key);

            if (string.IsNullOrEmpty(sql))
            {
                var dbEntity = DbEntityCache.GetDbEntity <T>(item);
                var fields   = ColumnField.GetFields(item);

                sql = CommandTextCache.GetUpdateCommandText(key, dbEntity, fields);
            }

            conn.Execute(sql, item, tran, null, CommandType.Text);
        }
 private static string BuildMultiQueryCondition(string alias, ColumnField field)
 {
     return(field.IsNullable ? $"(@{field.Name} IS NULL OR {alias}.[{field.Name}]=@{field.Name})" : $"{alias}.[{field.Name}]=@{field.Name}");
 }