Exemplo n.º 1
0
 public static bool Exists <T>(this DbContext connInfo, RequestBase param, string tableName = "")
     where T : new()
 {
     return(ExistsInTable(connInfo, GetTableName <T>(connInfo.DbType, tableName), param));
 }
Exemplo n.º 2
0
 public static IEnumerable <T> Select <T>(this DbContext db, string fields, RequestBase para, bool isExceptField, string tableName) where T : new()
 {
     return(db.SelectPrimitive <T>(para, fields.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries), isExceptField, tableName));
 }
Exemplo n.º 3
0
        /// <summary>
        /// conditionFilter 类似于 a.FieldName=#Para1# and b.FieldName=#Para2#
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="connInfo"></param>
        /// <param name="sql"></param>
        /// <param name="pars"></param>
        /// <param name="conditionFilter"></param>
        /// <param name="conditionList"></param>
        /// <returns></returns>
        public static IEnumerable <T> SelectCondition <T>(this DbContext connInfo, string sql, RequestBase param, string filter = "", Dictionary <string, object> condition = null)
            where T : new()
        {
            StringBuilder sqlbld = new StringBuilder(2048);

            sqlbld.Append(sql);
            bool hasCondi = (!string.IsNullOrEmpty(filter) || (null != condition && 0 < condition.Count));

            if (!hasCondi)
            {
                return(connInfo.Query <T>(sqlbld.ToString(), param));
            }
            bool containWhere = 0 <= sql.IndexOf(" WHERE ", StringComparison.OrdinalIgnoreCase);

            sqlbld.Append(containWhere ? " AND " : " WHERE ");
            sqlbld.Append(filter);
            AddParameters(condition, ref param);
            return(connInfo.Query <T>(sqlbld.ToString(), param));
        }
Exemplo n.º 4
0
 public static IEnumerable <T> Select <T>(this DbContext connInfo, RequestBase param, Expression <Func <T, object> > onlyFields = null, bool isExceptField = false, string tableName = "")
     where T : new()
 {
     return(SelectPrimitive <T>(connInfo, param, onlyFields?.GetPropertyNames <T>(), isExceptField, tableName));
 }
Exemplo n.º 5
0
 public static DataTable GetDataTable(this DbContext connInfo, string sql, RequestBase param,
                                      string filter = "", string orderStatement = "", Dictionary <string, object> condition = null)
 => SelectPageDataTable(connInfo, sql, param, 0, 0, filter, orderStatement, condition)?.DataList;