示例#1
0
        /// <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));
        }
示例#2
0
        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);
        }
示例#3
0
 public List <ClassName> ExecuteClassListQuery <ClassName>(string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod, params object[] parameters)
 {
     return(ExecuteClassListQuery(selectStatement, generateMethod, GetParametersFromObjectArray(parameters)));
 }
示例#4
0
 public List <ClassName> ExecuteClassListQuery <ClassName>(string selectStatement, ObjectFromDataReaderHandler <ClassName> generateMethod)
 {
     return(ExecuteClassListQuery(selectStatement, generateMethod, (object[])null));
 }
示例#5
0
        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);
        }
示例#6
0
 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)));
 }
示例#7
0
 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));
 }
示例#8
0
 /// <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)));
 }
示例#9
0
 /// <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));
 }
示例#10
0
        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);
        }
示例#11
0
 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)));
 }
示例#12
0
 public PagedList <ClassName> ExecutePagedClassListQuery <ClassName>(string storedProcedureName, ObjectFromDataReaderHandler <ClassName> generateMethod, int?startIndex, int?endIndex)
 {
     return(ExecutePagedClassListQuery(storedProcedureName, generateMethod, startIndex, endIndex, (object[])null));
 }