} = 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>())); } }
} = 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); }
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()); }
protected 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); }
protected 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 }); }
public WcfQueryResult QueryAll(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(_getEntities.MakeGenericMethod(typeArguments).Invoke(null, parameters)) { TotalCount = _totalCount }); }
//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 Base.Options.ExecuteType.ExecuteNonQuery: executeResult = Sql_Helper_DG.ExecuteNonQuery(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters); break; case Base.Options.ExecuteType.ExecuteScalar: executeResult = Sql_Helper_DG.ExecuteScalar(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters); break; case Base.Options.ExecuteType.ExecuteReader: executeResult = Sql_Helper_DG.ExecuteReader(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters); break; case Base.Options.ExecuteType.ExecuteDataTable: executeResult = Sql_Helper_DG.ExecuteDataTable(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters); break; case Base.Options.ExecuteType.ExecuteDataSet: executeResult = Sql_Helper_DG.ExecuteDataSet(query.SqlStatementTextOrSpName, query.SqlCommandType, query.SqlParameters); break; case Base.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 Base.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 Base.Options.ExecuteType._ChooseOthers_IfYouChooseThisYouWillGetAnException: throw new Exception("must choose the right ExecuteType ! -- QX_Frame"); } return(executeResult); }
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()); }
protected 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); }
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>())); }