Пример #1
0
        } = 0;                                           //the query result count

        private static int GetCount <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : DbContext where TBEntity : class
        {
            int count = 0;
            IQueryable <TBEntity> source = EF_Helper_DG <DBEntity> .SelectAll <TBEntity>(query.BuildQueryFunc <TBEntity>(), out count);

            return(count);
        }
        } = 0;                                           //the query result count

        private static int GetCount <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : Bankinate where TBEntity : class
        {
            using (var db = Activator.CreateInstance <DBEntity>())
            {
                return(db.QueryCount(query.BuildQueryFunc <TBEntity>()));
            }
        }
Пример #3
0
        private static object GetEntities <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : DbContext where TBEntity : class
        {
            IQueryable <TBEntity> source = null;
            int count = 0;

            source = EF_Helper_DG <DBEntity> .SelectAll(query.BuildQueryFunc <TBEntity>(), out count);

            _totalCount = count;
            return(source.ToList());
        }
Пример #4
0
 public int QueryCount(WcfQueryObject query)
 {
     if (query == null)
     {
         throw new ArgumentNullException("query");
     }
     System.Type[] typeArguments = new System.Type[] { query.db_type, query.tb_type };
     object[]      parameters    = new object[] { query };
     return((int)_getCount.MakeGenericMethod(typeArguments).Invoke(null, parameters));
 }
        private static object GetEntities <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : Bankinate where TBEntity : class
        {
            List <TBEntity> source = null;

            using (var db = Activator.CreateInstance <DBEntity>())
            {
                source = db.QueryEntities(query.BuildQueryFunc <TBEntity>());
            }
            _totalCount = source.Count;
            return(source);
        }
Пример #6
0
 public WcfQueryResult QuerySql(WcfQueryObject query)
 {
     if (query == null)
     {
         throw new ArgumentNullException("query");
     }
     System.Type[] typeArguments = new System.Type[] { query.db_type, query.tb_type };
     object[]      parameters    = new object[] { query };
     return(new WcfQueryResult(_executeSql.MakeGenericMethod(typeArguments).Invoke(null, parameters))
     {
         TotalCount = 1
     });
 }
Пример #7
0
        //sql query
        private static object ExecuteSql <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : DbContext where TBEntity : class
        {
            if (String.IsNullOrEmpty(query.SqlConnectionString))
            {
                throw new Exception("SqlConnectionString can not be null ! -- QX_Frame");
            }
            if (String.IsNullOrEmpty(query.SqlStatementTextOrSpName))
            {
                throw new Exception("QuerySqlStatementTextOrSpName can not be null ! -- QX_Frame");
            }
            //query execute
            object executeResult = new object();

            switch (query.SqlExecuteType)
            {
            case Options.ExecuteType.ExecuteNonQuery:
                executeResult = Sql_Helper_DG.ExecuteNonQuery(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters);
                break;

            case Options.ExecuteType.ExecuteScalar:
                executeResult = Sql_Helper_DG.ExecuteScalar(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters);
                break;

            case Options.ExecuteType.ExecuteReader:
                executeResult = Sql_Helper_DG.ExecuteReader(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters);
                break;

            case Options.ExecuteType.ExecuteDataTable:
                executeResult = Sql_Helper_DG.ExecuteDataTable(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters);
                break;

            case Options.ExecuteType.ExecuteDataSet:
                executeResult = Sql_Helper_DG.ExecuteDataSet(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters);
                break;

            case Options.ExecuteType.Execute_Model_T:
                executeResult = Sql_Helper_DG.Return_T_ByDataReader <TBEntity>(Sql_Helper_DG.ExecuteReader(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters));
                break;

            case Options.ExecuteType.Execute_List_T:
                executeResult = Sql_Helper_DG.Return_List_T_ByDataSet <TBEntity>(Sql_Helper_DG.ExecuteDataSet(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters));
                break;

            case Options.ExecuteType._ChooseOthers_IfYouChooseThisYouWillGetAnException:
                throw new Exception("must choose the right ExecuteType ! -- QX_Frame");
            }
            return(executeResult);
        }
Пример #8
0
        private static object GetEntitiesPaging <DBEntity, TBEntity, TKey>(WcfQueryObject <DBEntity, TBEntity> query, Expression <Func <TBEntity, TKey> > orderBy) where DBEntity : DbContext where TBEntity : class
        {
            IQueryable <TBEntity> source = null;
            int count = 0;

            if (query.PageIndex >= 0 && query.PageSize > 0)
            {
                source = EF_Helper_DG <DBEntity> .SelectAllPaging(query.PageIndex, query.PageSize, orderBy, query.BuildQueryFunc <TBEntity>(), out count, query.IsDESC);
            }
            else
            {
                source = EF_Helper_DG <DBEntity> .SelectAll(orderBy, query.BuildQueryFunc <TBEntity>(), out count, query.IsDESC);
            }
            _totalCount = count;
            return(source.ToList());
        }
Пример #9
0
 public WcfQueryResult QueryAllPaging <TBEntity, TKey>(WcfQueryObject query, Expression <Func <TBEntity, TKey> > orderBy) where TBEntity : class
 {
     if (query == null)
     {
         throw new ArgumentNullException("query");
     }
     if (orderBy == null)
     {
         throw new ArgumentNullException("if you want to paging must use OrderBy arguments  -- QX_Frame");
     }
     System.Type[] typeArguments = new System.Type[] { query.db_type, query.tb_type, typeof(TKey) };
     object[]      parameters    = new object[] { query, orderBy };
     return(new WcfQueryResult(_getEntitiesPaging.MakeGenericMethod(typeArguments).Invoke(null, parameters))
     {
         TotalCount = _totalCount
     });
 }
        private static object GetEntitiesPaging <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query, Expression <Func <TBEntity, object> > orderBy) where DBEntity : Bankinate where TBEntity : class
        {
            List <TBEntity> source = null;
            int             count  = 0;

            using (var db = Activator.CreateInstance <DBEntity>())
            {
                if (query.PageIndex >= 0 && query.PageSize > 0)
                {
                    source = db.QueryEntitiesPaging(query.PageIndex, query.PageSize, orderBy, query.BuildQueryFunc <TBEntity>(), out count, query.IsDESC);
                }
                else
                {
                    source = db.QueryEntitiesPaging(1, 10, orderBy, query.BuildQueryFunc <TBEntity>(), out count, query.IsDESC);
                }
            }
            _totalCount = source.Count;
            return(source);
        }
Пример #11
0
 private static object GetEntity <DBEntity, TBEntity>(WcfQueryObject <DBEntity, TBEntity> query) where DBEntity : DbContext where TBEntity : class
 {
     return(EF_Helper_DG <DBEntity> .SelectSingle(query.BuildQueryFunc <TBEntity>()));
 }