当前位置: 首页>>代码示例>>C#>>正文


C# MsSqlPersistence.ExecuteReader方法代码示例

本文整理汇总了C#中MsSqlPersistence.ExecuteReader方法的典型用法代码示例。如果您正苦于以下问题:C# MsSqlPersistence.ExecuteReader方法的具体用法?C# MsSqlPersistence.ExecuteReader怎么用?C# MsSqlPersistence.ExecuteReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MsSqlPersistence的用法示例。


在下文中一共展示了MsSqlPersistence.ExecuteReader方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetClientDocuments

        public SmartCollection<ClientDocument> GetClientDocuments(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int clientId)
        {
            var result = new SmartCollection<ClientDocument>();

            dbCommand.CommandType = CommandType.StoredProcedure;
            dbCommand.CommandText = "uspGetClientDocuments";
            dbCommand.Parameters.Clear();
            dbCommand.Parameters.AddWithValue("@ClientId", clientId);

            using (var reader = dbConnection.ExecuteReader(dbCommand)) {
                while (reader.Read()) {
                    result.Add(new ClientDocument {
                        ClientDocumentId = (int)reader["ClientDocumentID"],
                        Filename = reader["Filename"].ToString(),
                        CreatedBy = reader["CreatedBy"] != DBNull.Value ? Convert.ToInt32(reader["CreatedBy"]) : -1,
                        CreatedUser = reader["CreatedUser"].ToString(),
                        CreatedDate = reader["CreatedDate"] != DBNull.Value ? (DateTime)reader["CreatedDate"] : (DateTime)SqlDateTime.Null,
                        ModifiedBy = reader["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(reader["ModifiedBy"]) : -1,
                        ModifiedUser = reader["ModifiedUser"].ToString(),
                        ModifiedDate = reader["ModifiedDate"] != DBNull.Value ? (DateTime)reader["ModifiedDate"] : (DateTime)SqlDateTime.Null
                    });
                }
            }

            return result;
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:26,代码来源:ClientDAO.cs

示例2: GetClientsList

        public SmartCollection<Client> GetClientsList()
        {
            try {
                SmartCollection<Client> results = new SmartCollection<Client>();

                using (DbConnection = new MsSqlPersistence(DbConnectionSettings)) {
                    if (DbConnection.IsConnected()) {
                        using (DbCommand) {
                            DbCommand.CommandType = CommandType.StoredProcedure;
                            DbCommand.CommandText = "uspGetClientsList";
                            DbCommand.Parameters.Clear();
                            var reader = DbConnection.ExecuteReader(DbCommand);
                            results.AddRange(AutoMap.MapReaderToList<Client>(reader));
                        }
                    }else {
                        throw new Exception("Unable to Connect");
                    }
                }
                return results;
            }catch {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:23,代码来源:ClientDAO.cs

示例3: SearchModuleOrders


//.........这里部分代码省略.........
                            if (searchTests)
                            {
                                sql += @"
                                    LEFT JOIN orders_samples as samples ON samples.parentid = orders.id
                                    LEFT JOIN orders_samples_tests as tests ON tests.parentid = orders.id
                                    ";
                            }

                            if (serachAnalytes)
                            {
                                // NOTE: joining to seperate order_samples / order_samples_tests table aliases
                                //       is so searching tests and analytes can be be done independently or concurrently
                                sql += @"
                                    LEFT JOIN orders_samples as samples2 ON samples2.parentid = orders.id
                                    LEFT JOIN orders_samples_tests as tests2 ON tests2.parentid = orders.id
                                    LEFT JOIN orders_samples_analytes as analytes ON analytes.parentid = tests2.id
                                    ";
                            }

                            sql += @"
                                WHERE orders.delete_date IS NULL
                                ";

                            if (searchCustomers)
                            {
                                sql += @"
                                    AND customers.id = @customerId
                                    ";
                            }

                            if (searchDates)
                            {
                                sql += @"
                                    AND (received_date >= @orderReceivedStartDate and received_date <= @orderReceivedEndDate)
                                    ";
                            }

                            if (searchTests)
                            {
                                sql += @"
                                    AND tests.testid = @testId
                                    ";
                            }

                            if (serachAnalytes)
                            {
                                sql += @"
                                    AND analytes.analyteid = @analyteId
                                    ";
                            }

                            sql += @"
                                ORDER BY orders.received_date DESC
                                ";

                            DbCommand.CommandText = sql;

                            if (searchCustomers)
                            {
                                DbCommand.Parameters.AddWithValue("@customerId", customerId);
                            }

                            if (searchDates)
                            {
                                DbCommand.Parameters.AddWithValue("@orderReceivedStartDate", DateEx.GetStartOfDay(orderReceivedStartDate.Value));
                                DbCommand.Parameters.AddWithValue("@orderReceivedEndDate", DateEx.GetEndOfDay(orderReceivedEndDate.Value));
                            }

                            if (searchTests)
                            {
                                DbCommand.Parameters.AddWithValue("@testId", testId);
                            }

                            if (serachAnalytes)
                            {
                                DbCommand.Parameters.AddWithValue("@analyteId", analyteId);
                            }

                            var reader = DbConnection.ExecuteReader(DbCommand);
                            result.AddRange(AutoMap.MapReaderToList<Order>(reader));

                            foreach (var order in result)
                            {
                                using (var dao = new ClientDAO())
                                    order.Client = dao.GetClient(ref dbConnection, ref dbCommand, order.ParentId);
                            }
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
                return result;
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:101,代码来源:SampleDAO.cs

示例4: GetSampleTestContainers

 private SmartCollection<SampleTestContainer> GetSampleTestContainers(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int? sampleTestId)
 {
     SmartCollection<SampleTestContainer> returnList = new SmartCollection<SampleTestContainer>();
     try
     {
         dbCommand.CommandType = CommandType.StoredProcedure;
         dbCommand.CommandText = "uspGetSampleTestContainers";
         dbCommand.Parameters.Clear();
         dbCommand.Parameters.Add("@SampleTestId", System.Data.SqlDbType.Int).Value = sampleTestId;
         returnList.AddRange(AutoMap.MapReaderToList<SampleTestContainer>(dbConnection.ExecuteReader(dbCommand)));
     }
     catch
     {
         throw;
     }
     return returnList;
 }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:17,代码来源:SampleDAO.cs

示例5: GetSampleDocuments

        public SmartCollection<SampleDocument> GetSampleDocuments(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int arlNumber)
        {
            var result = new SmartCollection<SampleDocument>();

            dbCommand.CommandType = CommandType.StoredProcedure;
            dbCommand.CommandText = "uspGetSampleDocuments";

            dbCommand.Parameters.Clear();
            dbCommand.Parameters.AddWithValue("@ARLNumber", arlNumber);

            using (var reader = dbConnection.ExecuteReader(dbCommand))
            {
                while (reader.Read())
                {
                    result.Add(new SampleDocument
                    {
                        SampleDocumentId = Convert.ToInt32(reader["SampleDocumentID"]),
                        ARLNumber = Convert.ToInt32(reader["ARLNumber"]),
                        Filename = reader["Filename"].ToString(),
                        CreatedBy = reader["CreatedBy"] != DBNull.Value ? Convert.ToInt32(reader["CreatedBy"]) : new Int32(),
                        CreatedUser = reader["CreatedUser"].ToString(),
                        CreatedDate = reader["CreatedDate"] != DBNull.Value ? Convert.ToDateTime(reader["CreatedDate"]) : new DateTime(),
                        ModifiedBy = reader["ModifiedBy"] != DBNull.Value ? Convert.ToInt32(reader["ModifiedBy"]) : new Int32(),
                        ModifiedUser = reader["ModifiedUser"].ToString(),
                        ModifiedDate = reader["ModifiedDate"] != DBNull.Value ? Convert.ToDateTime(reader["ModifiedDate"]) : new DateTime()
                    });
                }
            }

            return result;
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:31,代码来源:SampleDAO.cs

示例6: GetSignature

        public UserSignature GetSignature(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int userId)
        {
            try
            {
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.CommandText = "uspGetSignature";
                dbCommand.Parameters.Clear();
                dbCommand.Parameters.Add("@UserId", System.Data.SqlDbType.Int).Value = userId;

                return AutoMap.MapReaderToObject<UserSignature>(dbConnection.ExecuteReader(dbCommand));
            }
            catch
            {
                throw;
            }
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:16,代码来源:UserDAO.cs

示例7: GetRole

 public Role GetRole(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, Guid roleId)
 {
     try {
         dbCommand.CommandType = CommandType.StoredProcedure;
         dbCommand.CommandText = "uspGetRole";
         dbCommand.Parameters.Clear();
         dbCommand.Parameters.Add("@RoleId", System.Data.SqlDbType.UniqueIdentifier).Value = roleId;
         return AutoMap.MapReaderToObject<Role>(dbConnection.ExecuteReader(dbCommand));
     }catch {
         throw;
     }
 }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:12,代码来源:UserDAO.cs

示例8: GetDepartment

 public Department GetDepartment(ref MsSqlPersistence dbConnection, ref SqlCommand dbCommand, int? departmentid)
 {
     try {
         dbCommand.CommandType = CommandType.StoredProcedure;
         dbCommand.CommandText = "uspGetDepartment";
         dbCommand.Parameters.Clear();
         dbCommand.Parameters.Add("@DepartmentId", System.Data.SqlDbType.Int).Value = departmentid;
         return AutoMap.MapReaderToObject<Department>(dbConnection.ExecuteReader(dbCommand));
     }catch {
         throw;
     }
 }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:12,代码来源:UserDAO.cs

示例9: GetReportNotifications

        public List<ReportNotification> GetReportNotifications()
        {
            List<ReportNotification> returnList = new List<ReportNotification>();
            try
            {
                using (DbConnection = new MsSqlPersistence(DbConnectionSettings, true))
                {
                    if (DbConnection.IsConnected())
                    {
                        using (DbCommand)
                        {
                            DbCommand.CommandText = @"
                                SELECT id, reportid, notificationid, departmentid, customerid, subjectline, created_date
                                FROM report_notifications
                                WHERE DATEDIFF(MINUTE,created_date,@CutoffDateTime) >= 5
                                ";

                            DbCommand.Parameters.Clear();
                            DbCommand.Parameters.AddWithValue("@CutoffDateTime", DateTime.Now);
                            returnList.AddRange(AutoMap.MapReaderToList<ReportNotification>(DbConnection.ExecuteReader(DbCommand)));
                        }
                    }
                    else
                    {
                        throw new Exception("Unable to Connect");
                    }
                }
            }
            catch
            {
                throw;
            }
            return returnList;
        }
开发者ID:jserna-arl,项目名称:LIMSv2,代码行数:34,代码来源:ReportDAO.cs


注:本文中的MsSqlPersistence.ExecuteReader方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。