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


C# SqlDatabase.BeginExecuteReader方法代码示例

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


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

示例1: getHealthVaultModelData

        internal static bool getHealthVaultModelData()
        {
            string connectionString = string.Empty;
            connectionString = @"Data Source=dev05\sql2k8;Initial Catalog=TSGPK_Healthvault;Integrated Security=True;Asynchronous Processing=true";
            Database dbGetHealthVaultModules = new SqlDatabase(connectionString);
            Database dbGetHealthVaultTypes = new SqlDatabase(connectionString);
            Database dbGetHealthTypeMapping = new SqlDatabase(connectionString);
            Database dbGetHealthVaultModuleTypeMapping = new SqlDatabase(connectionString);
            DbCommand cmdHealthVaultModules = dbGetHealthVaultModules.GetStoredProcCommand("TSG_HV_GetHealthVaultModules");
            DbCommand cmdHealthVaultTypes = dbGetHealthVaultTypes.GetStoredProcCommand("TSG_HV_GetHealthVaultTypes");
            DbCommand cmdHealthTypeMapping = dbGetHealthTypeMapping.GetStoredProcCommand("TSG_HV_GetHealthTypeMapping");
            DbCommand cmdHealthVaultModuleTypeMapping = dbGetHealthVaultModuleTypeMapping.GetStoredProcCommand("TSG_HV_GetHealthVaultModuleTypeMapping");

            try
            {

                IAsyncResult HealthVaultModules = dbGetHealthVaultModules.BeginExecuteReader(cmdHealthVaultModules, (res1) =>
                 {
                     Database db1 = (Database)res1.AsyncState;
                     using (IDataReader reader = db1.EndExecuteReader(res1))
                     {
                       while (reader.Read())
                         {
                             Console.WriteLine("HealthvaultModule");
                             var _healthvaultType = new HealthVaultType();
                             _healthvaultType.ID = Convert.ToInt32(reader["Id"]);
                             _healthvaultType.TypeName = Convert.ToString(reader["TypeName"]);
                             _healthvaultType.ModuleID = new Guid(reader["ModuleID"].ToString());
                             _healthvaultType.TypeIDs = Convert.ToString(reader["TypeIDs"]);
                             _healthvaultType.ClassName = Convert.ToString(reader["ClassName"]);
                             _healthvaultType.keyColumn = Convert.ToString(reader["KeyColumn"]);
                             _healthvaultType.keyColumnValue = Convert.ToString(reader["KeyColumnValue"]);
                             _healthvaultTypes.Add(_healthvaultType);
                         }
                         Interlocked.Increment(ref counter);
                         reader.Close();
                     }
                 }, dbGetHealthVaultModules);

                IAsyncResult HealthVaultFields = dbGetHealthVaultTypes.BeginExecuteReader(cmdHealthVaultTypes, (res2) =>
                {
                    Database db2 = (Database)res2.AsyncState;
                    using (IDataReader reader = db2.EndExecuteReader(res2))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleField");
                            var _field = new HealthVaultFields();
                            _field.FieldID = Convert.ToInt32(reader["DetailId"]);
                            _field.FieldName = Convert.ToString(reader["Name"]);
                            _field.FieldType = (Convert.ToBoolean(reader["isLookUp"])) ? "Codable" : "noncodable";
                            _field.isPremitive = Convert.ToBoolean(reader["isPremitiveType"]);
                            _field.PremitiveType = Convert.ToString(reader["PremitiveType"]);
                            _fields.Add(_field);
                        }
                        Interlocked.Increment(ref counter);
                        reader.Close();
                    }

                }, dbGetHealthVaultTypes);

                IAsyncResult HealthVaultModuleTypeMapping = dbGetHealthTypeMapping.BeginExecuteReader(cmdHealthTypeMapping, (res3) =>
                {
                    Database db3 = (Database)res3.AsyncState;
                    using (IDataReader reader = db3.EndExecuteReader(res3))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleTypeMapping");
                            var _subfield = new HealthVaultFieldsMapping();

                            _subfield.MappingID = Convert.ToInt32(reader["MappingID"]);
                            _subfield.MasterFieldID = Convert.ToInt32(reader["MasterTypeID"]);
                            _subfield.SubFieldID = Convert.ToInt32(reader["SubTypeID"]);
                            _subfield.isRequired = Convert.ToBoolean(reader["isRequired"]);
                            _mappings.Add(_subfield);
                        }
                        Interlocked.Increment(ref counter);
                        reader.Close();
                    }

                }, dbGetHealthTypeMapping);

                  IAsyncResult HealthTypeMapping = dbGetHealthVaultModuleTypeMapping.BeginExecuteReader(cmdHealthVaultModuleTypeMapping, (res4) =>
                {
                    Database db4 = (Database)res4.AsyncState;
                    using (IDataReader reader = db4.EndExecuteReader(res4))
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine("HealthvaultModuleFieldeMapping");
                            var _typemapping = new HealthVaultTypeFieldMapping();

                            _typemapping.MappingID = Convert.ToInt32(reader["ID"]);
                            _typemapping.ModuleID = Convert.ToInt32(reader["ModuleID"]);
                            _typemapping.MasterTypeID = Convert.ToInt32(reader["MasterTypeID"]);
                            _typemapping.FieldID = Convert.ToInt32(reader["isRequired"]);
                            _typemappings.Add(_typemapping);
                        }
                      Interlocked.Increment(ref counter);
//.........这里部分代码省略.........
开发者ID:yogitakanire,项目名称:HealthVaultService,代码行数:101,代码来源:RosyleneCompilation.cs


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