/// <summary> /// Executes the stored procedure with the given name, passes the provided parameters and used the generateMethod to return an instance of the passed generic type /// </summary> /// <typeparam name="ClassName">The type of the class to return.</typeparam> /// <param name="storedProcedureName">Name of the stored procedure.</param> /// <param name="generateMethod">The method expecting a DataRow and return an instance of the passed generic type.</param> /// <param name="parameters">The parameters.</param> /// <returns>An instance of the passed generic type</returns> public ClassName ExecuteClassQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, Dictionary <string, object> parameters) { if (parameters == null) { parameters = new Dictionary <string, object>(); } SqlDataReader reader = ExecuteReader(storedProcedureName, parameters); if (reader.Read()) { ClassName result = generateMethod(reader); DoPostCommandProcessing(); return(result); } return(default(ClassName)); }
public List <ClassName> ExecuteClassListQuery <ClassName>(string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, Dictionary <string, object> parameters) { if (parameters == null) { parameters = new Dictionary <string, object>(); } SQLiteDataReader reader = ExecuteReader(selectStatement, parameters); List <ClassName> result = new List <ClassName>(); while (reader.Read()) { result.Add(generateMethod(reader)); } DoPostCommandProcessing(); return(result); }
public List <ClassName> ExecuteClassListQuery <ClassName>(string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, params object[] parameters) { return(ExecuteClassListQuery(selectStatement, generateMethod, GetParametersFromObjectArray(parameters))); }
public List <ClassName> ExecuteClassListQuery <ClassName>(string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod) { return(ExecuteClassListQuery(selectStatement, generateMethod, (object[])null)); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string countStatement, string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex, Dictionary <string, object> parameters) { if (parameters == null) { parameters = new Dictionary <string, object>(); } int virtualCount = ExecuteScalar <int>(countStatement, parameters); SQLiteDataReader reader = ExecuteReader(selectStatement, parameters); PagedList <ClassName> result = new PagedList <ClassName> { VirtualCount = virtualCount }; while (reader.Read()) { result.Add(generateMethod(reader)); } DoPostCommandProcessing(); return(result); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string countStatement, string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex, params object[] parameters) { return(ExecutePagedClassListQuery(countStatement, selectStatement, generateMethod, startIndex, endIndex, GetParametersFromObjectArray(parameters))); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string countStatement, string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex) { return(ExecutePagedClassListQuery(countStatement, selectStatement, generateMethod, startIndex, endIndex, (object[])null)); }
/// <summary> /// Executes the stored procedure with the given name, passes the provided parameters and used the generateMethod to return an instance of the passed generic type /// </summary> /// <typeparam name="ClassName">The type of the class to return.</typeparam> /// <param name="storedProcedureName">Name of the stored procedure.</param> /// <param name="generateMethod">The method expecting a DataRow and return an instance of the passed generic type.</param> /// <param name="parameters">The parameters as objects in the shape of paramname, paramvalue, paramname, paramvalue and so on.</param> /// <returns>An instance of the passed generic type</returns> public ClassName ExecuteClassQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, params object[] parameters) { return(ExecuteClassQuery(storedProcedureName, generateMethod, GetParametersFromObjectArray(parameters))); }
/// <summary> /// Executes the stored procedure with the given name and used the generateMethod to return an instance of the passed generic type /// </summary> /// <typeparam name="ClassName">The type of the class to return.</typeparam> /// <param name="storedProcedureName">Name of the stored procedure.</param> /// <param name="generateMethod">The method expecting a DataRow and return an instance of the passed generic type.</param> /// <returns>An instance of the passed generic type </returns> public ClassName ExecuteClassQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod) { return(ExecuteClassQuery(storedProcedureName, generateMethod, (object[])null)); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex, Dictionary <string, object> parameters) { if (parameters == null) { parameters = new Dictionary <string, object>(); } SqlParameter virtualCountParameter = new SqlParameter("@VirtualCount", SqlDbType.Int) { Direction = ParameterDirection.Output }; SqlParameter startIndexParameter = new SqlParameter("@StartIndex", startIndex == null ? DBNull.Value : (object)startIndex.Value); SqlParameter endIndexParameter = new SqlParameter("@EndIndex", endIndex == null ? DBNull.Value : (object)endIndex.Value); SqlParameterCollection outputParameters; SqlDataReader reader = ExecuteReader(storedProcedureName, parameters, new[] { startIndexParameter, endIndexParameter, virtualCountParameter }, out outputParameters); PagedList <ClassName> result = new PagedList <ClassName> { VirtualCount = Convert.ToInt32(outputParameters["@VirtualCount"]) }; while (reader.Read()) { result.Add(generateMethod(reader)); } DoPostCommandProcessing(); return(result); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex, params object[] parameters) { return(ExecutePagedClassListQuery(storedProcedureName, generateMethod, startIndex, endIndex, GetParametersFromObjectArray(parameters))); }
public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex) { return(ExecutePagedClassListQuery(storedProcedureName, generateMethod, startIndex, endIndex, (object[])null)); }