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


C# SqlClient.SqlBulkCopy类代码示例

本文整理汇总了C#中System.Data.SqlClient.SqlBulkCopy的典型用法代码示例。如果您正苦于以下问题:C# System.Data.SqlClient.SqlBulkCopy类的具体用法?C# System.Data.SqlClient.SqlBulkCopy怎么用?C# System.Data.SqlClient.SqlBulkCopy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


System.Data.SqlClient.SqlBulkCopy类属于命名空间,在下文中一共展示了System.Data.SqlClient.SqlBulkCopy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.ProductPhoto object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<Nettiers.AdventureWorks.Entities.ProductPhoto> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "ProductPhoto";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("ProductPhotoID", typeof(System.Int32));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("ThumbNailPhoto", typeof(System.Byte[]));
			col1.AllowDBNull = true;		
			DataColumn col2 = dataTable.Columns.Add("ThumbnailPhotoFileName", typeof(System.String));
			col2.AllowDBNull = true;		
			DataColumn col3 = dataTable.Columns.Add("LargePhoto", typeof(System.Byte[]));
			col3.AllowDBNull = true;		
			DataColumn col4 = dataTable.Columns.Add("LargePhotoFileName", typeof(System.String));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("ModifiedDate", typeof(System.DateTime));
			col5.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("ProductPhotoID", "ProductPhotoID");
			bulkCopy.ColumnMappings.Add("ThumbNailPhoto", "ThumbNailPhoto");
			bulkCopy.ColumnMappings.Add("ThumbnailPhotoFileName", "ThumbnailPhotoFileName");
			bulkCopy.ColumnMappings.Add("LargePhoto", "LargePhoto");
			bulkCopy.ColumnMappings.Add("LargePhotoFileName", "LargePhotoFileName");
			bulkCopy.ColumnMappings.Add("ModifiedDate", "ModifiedDate");
			
			foreach(Nettiers.AdventureWorks.Entities.ProductPhoto entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["ProductPhotoID"] = entity.ProductPhotoId;
							
				
					row["ThumbNailPhoto"] = entity.ThumbNailPhoto;
							
				
					row["ThumbnailPhotoFileName"] = entity.ThumbnailPhotoFileName;
							
				
					row["LargePhoto"] = entity.LargePhoto;
							
				
					row["LargePhotoFileName"] = entity.LargePhotoFileName;
							
				
					row["ModifiedDate"] = entity.ModifiedDate;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(Nettiers.AdventureWorks.Entities.ProductPhoto entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
			}
		}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:90,代码来源:SqlProductPhotoProviderBase.generated.cs

示例2: BulkInsert

        /// <summary>
        /// Lets you efficiently bulk insert many entities to the database.
        /// </summary>
        /// <param name="transactionManager">The transaction manager.</param>
        /// <param name="entities">The entities.</param>
        /// <remarks>
        ///		After inserting into the datasource, the School.Entities.Students object will be updated
        /// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
        /// </remarks>	
        public override void BulkInsert(TransactionManager transactionManager, TList<School.Entities.Students> entities)
        {
            //System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);

            System.Data.SqlClient.SqlBulkCopy bulkCopy = null;

            if (transactionManager != null && transactionManager.IsOpen)
            {
                System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
                System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
                bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
            }
            else
            {
                bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
            }

            bulkCopy.BulkCopyTimeout = 360;
            bulkCopy.DestinationTableName = "Students";

            DataTable dataTable = new DataTable();
            DataColumn col0 = dataTable.Columns.Add("Id", typeof(System.Int32));
            col0.AllowDBNull = false;
            DataColumn col1 = dataTable.Columns.Add("Name", typeof(System.String));
            col1.AllowDBNull = false;
            DataColumn col2 = dataTable.Columns.Add("Address", typeof(System.String));
            col2.AllowDBNull = false;
            DataColumn col3 = dataTable.Columns.Add("ClassId", typeof(System.Int32));
            col3.AllowDBNull = false;
            DataColumn col4 = dataTable.Columns.Add("Birthdate", typeof(System.DateTime));
            col4.AllowDBNull = false;
            DataColumn col5 = dataTable.Columns.Add("Gender", typeof(System.String));
            col5.AllowDBNull = false;

            bulkCopy.ColumnMappings.Add("Id", "Id");
            bulkCopy.ColumnMappings.Add("Name", "Name");
            bulkCopy.ColumnMappings.Add("Address", "Address");
            bulkCopy.ColumnMappings.Add("ClassId", "ClassId");
            bulkCopy.ColumnMappings.Add("Birthdate", "Birthdate");
            bulkCopy.ColumnMappings.Add("Gender", "Gender");

            foreach(School.Entities.Students entity in entities)
            {
                if (entity.EntityState != EntityState.Added)
                    continue;

                DataRow row = dataTable.NewRow();

                    row["Id"] = entity.Id;

                    row["Name"] = entity.Name;

                    row["Address"] = entity.Address;

                    row["ClassId"] = entity.ClassId;

                    row["Birthdate"] = entity.Birthdate;

                    row["Gender"] = entity.Gender;

                dataTable.Rows.Add(row);
            }

            // send the data to the server
            bulkCopy.WriteToServer(dataTable);

            // update back the state
            foreach(School.Entities.Students entity in entities)
            {
                if (entity.EntityState != EntityState.Added)
                    continue;

                entity.AcceptChanges();
            }
        }
开发者ID:mario-loza,项目名称:School,代码行数:84,代码来源:SqlStudentsProviderBase.generated.cs

示例3: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.StoreContact object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<Nettiers.AdventureWorks.Entities.StoreContact> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "StoreContact";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("CustomerID", typeof(System.Int32));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("ContactID", typeof(System.Int32));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("ContactTypeID", typeof(System.Int32));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("rowguid", typeof(System.Guid));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("ModifiedDate", typeof(System.DateTime));
			col4.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("CustomerID", "CustomerID");
			bulkCopy.ColumnMappings.Add("ContactID", "ContactID");
			bulkCopy.ColumnMappings.Add("ContactTypeID", "ContactTypeID");
			bulkCopy.ColumnMappings.Add("rowguid", "rowguid");
			bulkCopy.ColumnMappings.Add("ModifiedDate", "ModifiedDate");
			
			foreach(Nettiers.AdventureWorks.Entities.StoreContact entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["CustomerID"] = entity.CustomerId;
							
				
					row["ContactID"] = entity.ContactId;
							
				
					row["ContactTypeID"] = entity.ContactTypeId;
							
				
					row["rowguid"] = entity.Rowguid;
							
				
					row["ModifiedDate"] = entity.ModifiedDate;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(Nettiers.AdventureWorks.Entities.StoreContact entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
			}
		}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:84,代码来源:SqlStoreContactProviderBase.generated.cs

示例4: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.Appointment object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<ClinicDoctor.Entities.Appointment> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "Appointment";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("Id", typeof(System.String));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("CustomerId", typeof(System.String));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("CustomerName", typeof(System.String));
			col2.AllowDBNull = true;		
			DataColumn col3 = dataTable.Columns.Add("ContentId", typeof(System.Int64));
			col3.AllowDBNull = true;		
			DataColumn col4 = dataTable.Columns.Add("ContentTitle", typeof(System.String));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("DoctorUsername", typeof(System.String));
			col5.AllowDBNull = true;		
			DataColumn col6 = dataTable.Columns.Add("DoctorShortName", typeof(System.String));
			col6.AllowDBNull = true;		
			DataColumn col7 = dataTable.Columns.Add("DoctorEmail", typeof(System.String));
			col7.AllowDBNull = true;		
			DataColumn col8 = dataTable.Columns.Add("RoomId", typeof(System.Int64));
			col8.AllowDBNull = true;		
			DataColumn col9 = dataTable.Columns.Add("RoomTitle", typeof(System.String));
			col9.AllowDBNull = true;		
			DataColumn col10 = dataTable.Columns.Add("NurseUsername", typeof(System.String));
			col10.AllowDBNull = true;		
			DataColumn col11 = dataTable.Columns.Add("NurseShortName", typeof(System.String));
			col11.AllowDBNull = true;		
			DataColumn col12 = dataTable.Columns.Add("StatusId", typeof(System.Int64));
			col12.AllowDBNull = true;		
			DataColumn col13 = dataTable.Columns.Add("StatusTitle", typeof(System.String));
			col13.AllowDBNull = true;		
			DataColumn col14 = dataTable.Columns.Add("Note", typeof(System.String));
			col14.AllowDBNull = true;		
			DataColumn col15 = dataTable.Columns.Add("StartTime", typeof(System.DateTime));
			col15.AllowDBNull = true;		
			DataColumn col16 = dataTable.Columns.Add("EndTime", typeof(System.DateTime));
			col16.AllowDBNull = true;		
			DataColumn col17 = dataTable.Columns.Add("ColorCode", typeof(System.String));
			col17.AllowDBNull = false;		
			DataColumn col18 = dataTable.Columns.Add("IsComplete", typeof(System.Boolean));
			col18.AllowDBNull = false;		
			DataColumn col19 = dataTable.Columns.Add("IsDisabled", typeof(System.Boolean));
			col19.AllowDBNull = false;		
			DataColumn col20 = dataTable.Columns.Add("CreateUser", typeof(System.String));
			col20.AllowDBNull = true;		
			DataColumn col21 = dataTable.Columns.Add("CreateDate", typeof(System.DateTime));
			col21.AllowDBNull = false;		
			DataColumn col22 = dataTable.Columns.Add("UpdateUser", typeof(System.String));
			col22.AllowDBNull = true;		
			DataColumn col23 = dataTable.Columns.Add("UpdateDate", typeof(System.DateTime));
			col23.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("Id", "Id");
			bulkCopy.ColumnMappings.Add("CustomerId", "CustomerId");
			bulkCopy.ColumnMappings.Add("CustomerName", "CustomerName");
			bulkCopy.ColumnMappings.Add("ContentId", "ContentId");
			bulkCopy.ColumnMappings.Add("ContentTitle", "ContentTitle");
			bulkCopy.ColumnMappings.Add("DoctorUsername", "DoctorUsername");
			bulkCopy.ColumnMappings.Add("DoctorShortName", "DoctorShortName");
			bulkCopy.ColumnMappings.Add("DoctorEmail", "DoctorEmail");
			bulkCopy.ColumnMappings.Add("RoomId", "RoomId");
			bulkCopy.ColumnMappings.Add("RoomTitle", "RoomTitle");
			bulkCopy.ColumnMappings.Add("NurseUsername", "NurseUsername");
			bulkCopy.ColumnMappings.Add("NurseShortName", "NurseShortName");
			bulkCopy.ColumnMappings.Add("StatusId", "StatusId");
			bulkCopy.ColumnMappings.Add("StatusTitle", "StatusTitle");
			bulkCopy.ColumnMappings.Add("Note", "Note");
			bulkCopy.ColumnMappings.Add("StartTime", "StartTime");
			bulkCopy.ColumnMappings.Add("EndTime", "EndTime");
			bulkCopy.ColumnMappings.Add("ColorCode", "ColorCode");
			bulkCopy.ColumnMappings.Add("IsComplete", "IsComplete");
			bulkCopy.ColumnMappings.Add("IsDisabled", "IsDisabled");
			bulkCopy.ColumnMappings.Add("CreateUser", "CreateUser");
//.........这里部分代码省略.........
开发者ID:williams55,项目名称:clinic-doctor,代码行数:101,代码来源:SqlAppointmentProviderBase.generated.cs

示例5: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Orders object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<PetShop.Business.Orders> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "Orders";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("OrderId", typeof(int));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("UserId", typeof(string));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("OrderDate", typeof(System.DateTime));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("ShipAddr1", typeof(string));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("ShipAddr2", typeof(string));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("ShipCity", typeof(string));
			col5.AllowDBNull = false;		
			DataColumn col6 = dataTable.Columns.Add("ShipState", typeof(string));
			col6.AllowDBNull = false;		
			DataColumn col7 = dataTable.Columns.Add("ShipZip", typeof(string));
			col7.AllowDBNull = false;		
			DataColumn col8 = dataTable.Columns.Add("ShipCountry", typeof(string));
			col8.AllowDBNull = false;		
			DataColumn col9 = dataTable.Columns.Add("BillAddr1", typeof(string));
			col9.AllowDBNull = false;		
			DataColumn col10 = dataTable.Columns.Add("BillAddr2", typeof(string));
			col10.AllowDBNull = true;		
			DataColumn col11 = dataTable.Columns.Add("BillCity", typeof(string));
			col11.AllowDBNull = false;		
			DataColumn col12 = dataTable.Columns.Add("BillState", typeof(string));
			col12.AllowDBNull = false;		
			DataColumn col13 = dataTable.Columns.Add("BillZip", typeof(string));
			col13.AllowDBNull = false;		
			DataColumn col14 = dataTable.Columns.Add("BillCountry", typeof(string));
			col14.AllowDBNull = false;		
			DataColumn col15 = dataTable.Columns.Add("Courier", typeof(string));
			col15.AllowDBNull = false;		
			DataColumn col16 = dataTable.Columns.Add("TotalPrice", typeof(decimal));
			col16.AllowDBNull = false;		
			DataColumn col17 = dataTable.Columns.Add("BillToFirstName", typeof(string));
			col17.AllowDBNull = false;		
			DataColumn col18 = dataTable.Columns.Add("BillToLastName", typeof(string));
			col18.AllowDBNull = false;		
			DataColumn col19 = dataTable.Columns.Add("ShipToFirstName", typeof(string));
			col19.AllowDBNull = false;		
			DataColumn col20 = dataTable.Columns.Add("ShipToLastName", typeof(string));
			col20.AllowDBNull = false;		
			DataColumn col21 = dataTable.Columns.Add("AuthorizationNumber", typeof(int));
			col21.AllowDBNull = false;		
			DataColumn col22 = dataTable.Columns.Add("Locale", typeof(string));
			col22.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("OrderId", "OrderId");
			bulkCopy.ColumnMappings.Add("UserId", "UserId");
			bulkCopy.ColumnMappings.Add("OrderDate", "OrderDate");
			bulkCopy.ColumnMappings.Add("ShipAddr1", "ShipAddr1");
			bulkCopy.ColumnMappings.Add("ShipAddr2", "ShipAddr2");
			bulkCopy.ColumnMappings.Add("ShipCity", "ShipCity");
			bulkCopy.ColumnMappings.Add("ShipState", "ShipState");
			bulkCopy.ColumnMappings.Add("ShipZip", "ShipZip");
			bulkCopy.ColumnMappings.Add("ShipCountry", "ShipCountry");
			bulkCopy.ColumnMappings.Add("BillAddr1", "BillAddr1");
			bulkCopy.ColumnMappings.Add("BillAddr2", "BillAddr2");
			bulkCopy.ColumnMappings.Add("BillCity", "BillCity");
			bulkCopy.ColumnMappings.Add("BillState", "BillState");
			bulkCopy.ColumnMappings.Add("BillZip", "BillZip");
			bulkCopy.ColumnMappings.Add("BillCountry", "BillCountry");
			bulkCopy.ColumnMappings.Add("Courier", "Courier");
			bulkCopy.ColumnMappings.Add("TotalPrice", "TotalPrice");
			bulkCopy.ColumnMappings.Add("BillToFirstName", "BillToFirstName");
			bulkCopy.ColumnMappings.Add("BillToLastName", "BillToLastName");
			bulkCopy.ColumnMappings.Add("ShipToFirstName", "ShipToFirstName");
			bulkCopy.ColumnMappings.Add("ShipToLastName", "ShipToLastName");
			bulkCopy.ColumnMappings.Add("AuthorizationNumber", "AuthorizationNumber");
			bulkCopy.ColumnMappings.Add("Locale", "Locale");
//.........这里部分代码省略.........
开发者ID:netTiers,项目名称:netTiers,代码行数:101,代码来源:SqlOrdersProviderBase.generated.cs

示例6: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.TimestampPk object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<Nettiers.AdventureWorks.Entities.TimestampPk> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "TimestampPK";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("TimestampPK", typeof(System.Byte[]));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("SomeText", typeof(System.String));
			col1.AllowDBNull = true;		
			
			bulkCopy.ColumnMappings.Add("TimestampPK", "TimestampPK");
			bulkCopy.ColumnMappings.Add("SomeText", "SomeText");
			
			foreach(Nettiers.AdventureWorks.Entities.TimestampPk entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["TimestampPK"] = entity.TimestampPk;
							
				
					row["SomeText"] = entity.SomeText;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(Nettiers.AdventureWorks.Entities.TimestampPk entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
			}
		}
开发者ID:WildGenie,项目名称:NetTiers,代码行数:66,代码来源:SqlTimestampPkProviderBase.generated.cs

示例7: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.SalesPerson object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<Nettiers.AdventureWorks.Entities.SalesPerson> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "SalesPerson";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("SalesPersonID", typeof(System.Int32));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("TerritoryID", typeof(System.Int32));
			col1.AllowDBNull = true;		
			DataColumn col2 = dataTable.Columns.Add("SalesQuota", typeof(System.Decimal));
			col2.AllowDBNull = true;		
			DataColumn col3 = dataTable.Columns.Add("Bonus", typeof(System.Decimal));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("CommissionPct", typeof(System.Decimal));
			col4.AllowDBNull = false;		
			DataColumn col5 = dataTable.Columns.Add("SalesYTD", typeof(System.Decimal));
			col5.AllowDBNull = false;		
			DataColumn col6 = dataTable.Columns.Add("SalesLastYear", typeof(System.Decimal));
			col6.AllowDBNull = false;		
			DataColumn col7 = dataTable.Columns.Add("rowguid", typeof(System.Guid));
			col7.AllowDBNull = false;		
			DataColumn col8 = dataTable.Columns.Add("ModifiedDate", typeof(System.DateTime));
			col8.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("SalesPersonID", "SalesPersonID");
			bulkCopy.ColumnMappings.Add("TerritoryID", "TerritoryID");
			bulkCopy.ColumnMappings.Add("SalesQuota", "SalesQuota");
			bulkCopy.ColumnMappings.Add("Bonus", "Bonus");
			bulkCopy.ColumnMappings.Add("CommissionPct", "CommissionPct");
			bulkCopy.ColumnMappings.Add("SalesYTD", "SalesYTD");
			bulkCopy.ColumnMappings.Add("SalesLastYear", "SalesLastYear");
			bulkCopy.ColumnMappings.Add("rowguid", "rowguid");
			bulkCopy.ColumnMappings.Add("ModifiedDate", "ModifiedDate");
			
			foreach(Nettiers.AdventureWorks.Entities.SalesPerson entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["SalesPersonID"] = entity.SalesPersonId;
							
				
					row["TerritoryID"] = entity.TerritoryId.HasValue ? (object) entity.TerritoryId  : System.DBNull.Value;
							
				
					row["SalesQuota"] = entity.SalesQuota.HasValue ? (object) entity.SalesQuota  : System.DBNull.Value;
							
				
					row["Bonus"] = entity.Bonus;
							
				
					row["CommissionPct"] = entity.CommissionPct;
							
				
					row["SalesYTD"] = entity.SalesYtd;
							
				
					row["SalesLastYear"] = entity.SalesLastYear;
							
				
					row["rowguid"] = entity.Rowguid;
							
				
					row["ModifiedDate"] = entity.ModifiedDate;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
//.........这里部分代码省略.........
开发者ID:WildGenie,项目名称:NetTiers,代码行数:101,代码来源:SqlSalesPersonProviderBase.generated.cs

示例8: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the ClinicDoctor.Entities.Staff object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<ClinicDoctor.Entities.Staff> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "Staff";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("Id", typeof(System.Int64));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("FirstName", typeof(System.String));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("LastName", typeof(System.String));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("ShortName", typeof(System.String));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("UserName", typeof(System.String));
			col4.AllowDBNull = false;		
			DataColumn col5 = dataTable.Columns.Add("Email", typeof(System.String));
			col5.AllowDBNull = true;		
			DataColumn col6 = dataTable.Columns.Add("Address", typeof(System.String));
			col6.AllowDBNull = true;		
			DataColumn col7 = dataTable.Columns.Add("HomePhone", typeof(System.String));
			col7.AllowDBNull = true;		
			DataColumn col8 = dataTable.Columns.Add("WorkPhone", typeof(System.String));
			col8.AllowDBNull = true;		
			DataColumn col9 = dataTable.Columns.Add("CellPhone", typeof(System.String));
			col9.AllowDBNull = true;		
			DataColumn col10 = dataTable.Columns.Add("Birthdate", typeof(System.DateTime));
			col10.AllowDBNull = true;		
			DataColumn col11 = dataTable.Columns.Add("IsFemale", typeof(System.Boolean));
			col11.AllowDBNull = false;		
			DataColumn col12 = dataTable.Columns.Add("Title", typeof(System.String));
			col12.AllowDBNull = true;		
			DataColumn col13 = dataTable.Columns.Add("Note", typeof(System.String));
			col13.AllowDBNull = true;		
			DataColumn col14 = dataTable.Columns.Add("Roles", typeof(System.String));
			col14.AllowDBNull = false;		
			DataColumn col15 = dataTable.Columns.Add("IsDisabled", typeof(System.Boolean));
			col15.AllowDBNull = false;		
			DataColumn col16 = dataTable.Columns.Add("CreateUser", typeof(System.String));
			col16.AllowDBNull = true;		
			DataColumn col17 = dataTable.Columns.Add("CreateDate", typeof(System.DateTime));
			col17.AllowDBNull = false;		
			DataColumn col18 = dataTable.Columns.Add("UpdateUser", typeof(System.String));
			col18.AllowDBNull = true;		
			DataColumn col19 = dataTable.Columns.Add("UpdateDate", typeof(System.DateTime));
			col19.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("Id", "Id");
			bulkCopy.ColumnMappings.Add("FirstName", "FirstName");
			bulkCopy.ColumnMappings.Add("LastName", "LastName");
			bulkCopy.ColumnMappings.Add("ShortName", "ShortName");
			bulkCopy.ColumnMappings.Add("UserName", "UserName");
			bulkCopy.ColumnMappings.Add("Email", "Email");
			bulkCopy.ColumnMappings.Add("Address", "Address");
			bulkCopy.ColumnMappings.Add("HomePhone", "HomePhone");
			bulkCopy.ColumnMappings.Add("WorkPhone", "WorkPhone");
			bulkCopy.ColumnMappings.Add("CellPhone", "CellPhone");
			bulkCopy.ColumnMappings.Add("Birthdate", "Birthdate");
			bulkCopy.ColumnMappings.Add("IsFemale", "IsFemale");
			bulkCopy.ColumnMappings.Add("Title", "Title");
			bulkCopy.ColumnMappings.Add("Note", "Note");
			bulkCopy.ColumnMappings.Add("Roles", "Roles");
			bulkCopy.ColumnMappings.Add("IsDisabled", "IsDisabled");
			bulkCopy.ColumnMappings.Add("CreateUser", "CreateUser");
			bulkCopy.ColumnMappings.Add("CreateDate", "CreateDate");
			bulkCopy.ColumnMappings.Add("UpdateUser", "UpdateUser");
			bulkCopy.ColumnMappings.Add("UpdateDate", "UpdateDate");
			
			foreach(ClinicDoctor.Entities.Staff entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["Id"] = entity.Id;
//.........这里部分代码省略.........
开发者ID:williams55,项目名称:clinic-doctor,代码行数:101,代码来源:SqlStaffProviderBase.generated.cs

示例9: BulkInsert

        /// <summary>
        /// Lets you efficiently bulk insert many entities to the database.
        /// </summary>
        /// <param name="transactionManager">The transaction manager.</param>
        /// <param name="entities">The entities.</param>
        /// <remarks>
        ///		After inserting into the datasource, the Library.BLL.BookImage object will be updated
        /// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
        /// </remarks>	
        public override void BulkInsert(TransactionManager transactionManager, TList<Library.BLL.BookImage> entities)
        {
            //System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);

            System.Data.SqlClient.SqlBulkCopy bulkCopy = null;

            if (transactionManager != null && transactionManager.IsOpen)
            {
                System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
                System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
                bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
            }
            else
            {
                bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
            }

            bulkCopy.BulkCopyTimeout = 360;
            bulkCopy.DestinationTableName = "BookImage";

            DataTable dataTable = new DataTable();
            DataColumn col0 = dataTable.Columns.Add("ID", typeof(System.Int32));
            col0.AllowDBNull = false;
            DataColumn col1 = dataTable.Columns.Add("Name", typeof(System.String));
            col1.AllowDBNull = false;
            DataColumn col2 = dataTable.Columns.Add("Format", typeof(System.String));
            col2.AllowDBNull = true;
            DataColumn col3 = dataTable.Columns.Add("Size", typeof(System.String));
            col3.AllowDBNull = true;
            DataColumn col4 = dataTable.Columns.Add("Link", typeof(System.String));
            col4.AllowDBNull = true;
            DataColumn col5 = dataTable.Columns.Add("IsAvailable", typeof(System.String));
            col5.AllowDBNull = true;

            bulkCopy.ColumnMappings.Add("ID", "ID");
            bulkCopy.ColumnMappings.Add("Name", "Name");
            bulkCopy.ColumnMappings.Add("Format", "Format");
            bulkCopy.ColumnMappings.Add("Size", "Size");
            bulkCopy.ColumnMappings.Add("Link", "Link");
            bulkCopy.ColumnMappings.Add("IsAvailable", "IsAvailable");

            foreach(Library.BLL.BookImage entity in entities)
            {
                if (entity.EntityState != EntityState.Added)
                    continue;

                DataRow row = dataTable.NewRow();

                    row["ID"] = entity.ID;

                    row["Name"] = entity.Name;

                    row["Format"] = entity.Format;

                    row["Size"] = entity.Size;

                    row["Link"] = entity.Link;

                    row["IsAvailable"] = entity.IsAvailable;

                dataTable.Rows.Add(row);
            }

            // send the data to the server
            bulkCopy.WriteToServer(dataTable);

            // update back the state
            foreach(Library.BLL.BookImage entity in entities)
            {
                if (entity.EntityState != EntityState.Added)
                    continue;

                entity.AcceptChanges();
            }
        }
开发者ID:YasienDwieb,项目名称:Library,代码行数:84,代码来源:SqlBookImageProviderBase.generated.cs

示例10: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.Supplier object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<PetShop.Business.Supplier> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "Supplier";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("SuppId", typeof(int));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("Name", typeof(string));
			col1.AllowDBNull = true;		
			DataColumn col2 = dataTable.Columns.Add("Status", typeof(string));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("Addr1", typeof(string));
			col3.AllowDBNull = true;		
			DataColumn col4 = dataTable.Columns.Add("Addr2", typeof(string));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("City", typeof(string));
			col5.AllowDBNull = true;		
			DataColumn col6 = dataTable.Columns.Add("State", typeof(string));
			col6.AllowDBNull = true;		
			DataColumn col7 = dataTable.Columns.Add("Zip", typeof(string));
			col7.AllowDBNull = true;		
			DataColumn col8 = dataTable.Columns.Add("Phone", typeof(string));
			col8.AllowDBNull = true;		
			
			bulkCopy.ColumnMappings.Add("SuppId", "SuppId");
			bulkCopy.ColumnMappings.Add("Name", "Name");
			bulkCopy.ColumnMappings.Add("Status", "Status");
			bulkCopy.ColumnMappings.Add("Addr1", "Addr1");
			bulkCopy.ColumnMappings.Add("Addr2", "Addr2");
			bulkCopy.ColumnMappings.Add("City", "City");
			bulkCopy.ColumnMappings.Add("State", "State");
			bulkCopy.ColumnMappings.Add("Zip", "Zip");
			bulkCopy.ColumnMappings.Add("Phone", "Phone");
			
			foreach(PetShop.Business.Supplier entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["SuppId"] = entity.SuppId;
							
				
					row["Name"] = entity.Name;
							
				
					row["Status"] = entity.Status;
							
				
					row["Addr1"] = entity.Addr1;
							
				
					row["Addr2"] = entity.Addr2;
							
				
					row["City"] = entity.City;
							
				
					row["State"] = entity.State;
							
				
					row["Zip"] = entity.Zip;
							
				
					row["Phone"] = entity.Phone;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
//.........这里部分代码省略.........
开发者ID:netTiers,项目名称:netTiers,代码行数:101,代码来源:SqlSupplierProviderBase.generated.cs

示例11: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the Nettiers.AdventureWorks.Entities.DatabaseLog object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<Nettiers.AdventureWorks.Entities.DatabaseLog> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "DatabaseLog";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("DatabaseLogID", typeof(System.Int32));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("PostTime", typeof(System.DateTime));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("DatabaseUser", typeof(System.String));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("Event", typeof(System.String));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("Schema", typeof(System.String));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("Object", typeof(System.String));
			col5.AllowDBNull = true;		
			DataColumn col6 = dataTable.Columns.Add("TSQL", typeof(System.String));
			col6.AllowDBNull = false;		
			DataColumn col7 = dataTable.Columns.Add("XmlEvent", typeof(string));
			col7.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("DatabaseLogID", "DatabaseLogID");
			bulkCopy.ColumnMappings.Add("PostTime", "PostTime");
			bulkCopy.ColumnMappings.Add("DatabaseUser", "DatabaseUser");
			bulkCopy.ColumnMappings.Add("Event", "Event");
			bulkCopy.ColumnMappings.Add("Schema", "Schema");
			bulkCopy.ColumnMappings.Add("Object", "Object");
			bulkCopy.ColumnMappings.Add("TSQL", "TSQL");
			bulkCopy.ColumnMappings.Add("XmlEvent", "XmlEvent");
			
			foreach(Nettiers.AdventureWorks.Entities.DatabaseLog entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["DatabaseLogID"] = entity.DatabaseLogId;
							
				
					row["PostTime"] = entity.PostTime;
							
				
					row["DatabaseUser"] = entity.DatabaseUser;
							
				
					row["Event"] = entity.SafeNameEvent;
							
				
					row["Schema"] = entity.Schema;
							
				
					row["Object"] = entity.SafeNameObject;
							
				
					row["TSQL"] = entity.Tsql;
							
				
					row["XmlEvent"] = entity.XmlEvent;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(Nettiers.AdventureWorks.Entities.DatabaseLog entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
//.........这里部分代码省略.........
开发者ID:WildGenie,项目名称:NetTiers,代码行数:101,代码来源:SqlDatabaseLogProviderBase.generated.cs

示例12: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the PetShop.Business.OrderStatus object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<PetShop.Business.OrderStatus> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "OrderStatus";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("OrderId", typeof(int));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("LineNum", typeof(int));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("Timestamp", typeof(System.DateTime));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("Status", typeof(string));
			col3.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("OrderId", "OrderId");
			bulkCopy.ColumnMappings.Add("LineNum", "LineNum");
			bulkCopy.ColumnMappings.Add("Timestamp", "Timestamp");
			bulkCopy.ColumnMappings.Add("Status", "Status");
			
			foreach(PetShop.Business.OrderStatus entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["OrderId"] = entity.OrderId;
							
				
					row["LineNum"] = entity.LineNum;
							
				
					row["Timestamp"] = entity.Timestamp;
							
				
					row["Status"] = entity.Status;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(PetShop.Business.OrderStatus entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
			}
		}
开发者ID:netTiers,项目名称:netTiers,代码行数:78,代码来源:SqlOrderStatusProviderBase.generated.cs

示例13: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk many entity to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the SmartMassEmail.Entities.EmailMessageDetail object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<SmartMassEmail.Entities.EmailMessageDetail> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "EmailMessageDetail";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("ID", typeof(System.Guid));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("ChangeStamp", typeof(System.DateTime));
			col1.AllowDBNull = false;		
			DataColumn col2 = dataTable.Columns.Add("IsBinary", typeof(System.Int32));
			col2.AllowDBNull = false;		
			DataColumn col3 = dataTable.Columns.Add("Name", typeof(System.String));
			col3.AllowDBNull = false;		
			DataColumn col4 = dataTable.Columns.Add("BinaryData", typeof(System.Byte[]));
			col4.AllowDBNull = false;		
			DataColumn col5 = dataTable.Columns.Add("StringData", typeof(System.String));
			col5.AllowDBNull = false;		
			DataColumn col6 = dataTable.Columns.Add("EmailMessageID", typeof(System.Guid));
			col6.AllowDBNull = false;		
			
			bulkCopy.ColumnMappings.Add("ID", "ID");
			bulkCopy.ColumnMappings.Add("ChangeStamp", "ChangeStamp");
			bulkCopy.ColumnMappings.Add("IsBinary", "IsBinary");
			bulkCopy.ColumnMappings.Add("Name", "Name");
			bulkCopy.ColumnMappings.Add("BinaryData", "BinaryData");
			bulkCopy.ColumnMappings.Add("StringData", "StringData");
			bulkCopy.ColumnMappings.Add("EmailMessageID", "EmailMessageID");
			
			foreach(SmartMassEmail.Entities.EmailMessageDetail entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["ID"] = entity.ID;
							
				
					row["ChangeStamp"] = entity.ChangeStamp;
							
				
					row["IsBinary"] = entity.IsBinary;
							
				
					row["Name"] = entity.Name;
							
				
					row["BinaryData"] = entity.BinaryData;
							
				
					row["StringData"] = entity.StringData;
							
				
					row["EmailMessageID"] = entity.EmailMessageID;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
			foreach(SmartMassEmail.Entities.EmailMessageDetail entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
			
				entity.AcceptChanges();
			}
		}
开发者ID:chibuk,项目名称:krooe,代码行数:96,代码来源:SqlEmailMessageDetailProviderBase.generated.cs

示例14: OleCopyToTempTable

        /// <summary>
        /// Use bulk copy to insert the worksheet rows into the specified table
        /// </summary>
        /// <param name="tempTableName"></param>
        /// <param name="excelConnectionString"></param>
        /// <param name="worksheetName"></param>
        private void OleCopyToTempTable(string tempTableName, string excelConnectionString, string worksheetName)
        {
            using (System.Data.OleDb.OleDbConnection excelConnection = new System.Data.OleDb.OleDbConnection(excelConnectionString))
            {
                try
                {
                    excelConnection.Open();
                    if (string.IsNullOrEmpty(ExcelQuery))
                        ExcelQuery = "SELECT * FROM [" + worksheetName + "$]";
                    else
                        ExcelQuery += "FROM [" + worksheetName + "$]";
                    using (System.Data.OleDb.OleDbCommand selectAllComand = new System.Data.OleDb.OleDbCommand(ExcelQuery))   //SELECT * FROM [" + worksheetName + "$]"))
                    {
                        selectAllComand.Connection = excelConnection;
                        using (System.Data.OleDb.OleDbDataReader excelReader = selectAllComand.ExecuteReader())
                        {

                            using (System.Data.SqlClient.SqlBulkCopy bc = new System.Data.SqlClient.SqlBulkCopy(_dbConn))
                            {
                                bc.BatchSize = 50;

                                bc.DestinationTableName = @"[dbo].[" + tempTableName + @"]"; //tempDatasheetImport]";
                                // User notification with the SqlRowsCopied event
                                //bc.NotifyAfter = 100;
                                //bc.SqlRowsCopied += new SqlRowsCopiedEventHandler(OnSqlRowsCopied);
                                if (_dbConn.State != System.Data.ConnectionState.Open)
                                    _dbConn.Open();
                                bc.WriteToServer(excelReader);
                                bc.Close();
                            }
                            excelReader.Close();
                            _dbConn.Close();
                        }

                    }
                    excelConnection.Close();
                }
                catch (InvalidOperationException ex)
                {
                    //if (ex.Message != @"Column 'tmpIndentNo' does not allow DBNull.Value.") //not a problem, just reaching the footer and easier to skip an exception than try to filter it out
                    //    throw new Exception("OleCopyToTempTable 1: " + ex.Message);
                    //else if (ex.Message != @"Column 'tmpMSEP' does not allow DBNull.Value.") //not a problem, just reaching the footer
                    //    throw new Exception("OleCopyToTempTable 2: " + ex.Message);
                    //else if (ex.Message != @"Column 'tmpIndentNo' does not allow DBNull.Value.")
                    //    throw new Exception("OleCopyToTempTable 3: " + ex.Message);
                }
                finally
                {
                    excelConnection.Close();
                    _dbConn.Close();

                }
                //catch (Exception ex)
                //{
                //    throw new Exception("OleCopyToTempTable 4: " + ex.Message);
                //}
            }
        }
开发者ID:MarneeDear,项目名称:Terminal-Management-Applications,代码行数:64,代码来源:DatasheetProcessing.cs

示例15: BulkInsert

		/// <summary>
		/// Lets you efficiently bulk insert many entities to the database.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="entities">The entities.</param>
		/// <remarks>
		///		After inserting into the datasource, the HearbalKartDB.Entities.States object will be updated
		/// 	to refelect any changes made by the datasource. (ie: identity or computed columns)
		/// </remarks>	
		public override void BulkInsert(TransactionManager transactionManager, TList<HearbalKartDB.Entities.States> entities)
		{
			//System.Data.SqlClient.SqlBulkCopy bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			
			System.Data.SqlClient.SqlBulkCopy bulkCopy = null;
	
			if (transactionManager != null && transactionManager.IsOpen)
			{			
				System.Data.SqlClient.SqlConnection cnx = transactionManager.TransactionObject.Connection as System.Data.SqlClient.SqlConnection;
				System.Data.SqlClient.SqlTransaction transaction = transactionManager.TransactionObject as System.Data.SqlClient.SqlTransaction;
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(cnx, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints, transaction); //, null);
			}
			else
			{
				bulkCopy = new System.Data.SqlClient.SqlBulkCopy(this._connectionString, System.Data.SqlClient.SqlBulkCopyOptions.CheckConstraints); //, null);
			}
			
			bulkCopy.BulkCopyTimeout = 360;
			bulkCopy.DestinationTableName = "States";
			
			DataTable dataTable = new DataTable();
			DataColumn col0 = dataTable.Columns.Add("ID", typeof(System.Int32));
			col0.AllowDBNull = false;		
			DataColumn col1 = dataTable.Columns.Add("CountryID", typeof(System.Int32));
			col1.AllowDBNull = true;		
			DataColumn col2 = dataTable.Columns.Add("Name", typeof(System.String));
			col2.AllowDBNull = true;		
			DataColumn col3 = dataTable.Columns.Add("Pin", typeof(System.Int64));
			col3.AllowDBNull = true;		
			DataColumn col4 = dataTable.Columns.Add("IsActive", typeof(System.Boolean));
			col4.AllowDBNull = true;		
			DataColumn col5 = dataTable.Columns.Add("CreatedDate", typeof(System.DateTime));
			col5.AllowDBNull = true;		
			DataColumn col6 = dataTable.Columns.Add("ModifiedDate", typeof(System.DateTime));
			col6.AllowDBNull = true;		
			DataColumn col7 = dataTable.Columns.Add("DeletedDate", typeof(System.DateTime));
			col7.AllowDBNull = true;		
			DataColumn col8 = dataTable.Columns.Add("PinCode", typeof(System.String));
			col8.AllowDBNull = true;		
			
			bulkCopy.ColumnMappings.Add("ID", "ID");
			bulkCopy.ColumnMappings.Add("CountryID", "CountryID");
			bulkCopy.ColumnMappings.Add("Name", "Name");
			bulkCopy.ColumnMappings.Add("Pin", "Pin");
			bulkCopy.ColumnMappings.Add("IsActive", "IsActive");
			bulkCopy.ColumnMappings.Add("CreatedDate", "CreatedDate");
			bulkCopy.ColumnMappings.Add("ModifiedDate", "ModifiedDate");
			bulkCopy.ColumnMappings.Add("DeletedDate", "DeletedDate");
			bulkCopy.ColumnMappings.Add("PinCode", "PinCode");
			
			foreach(HearbalKartDB.Entities.States entity in entities)
			{
				if (entity.EntityState != EntityState.Added)
					continue;
					
				DataRow row = dataTable.NewRow();
				
					row["ID"] = entity.Id;
							
				
					row["CountryID"] = entity.CountryId.HasValue ? (object) entity.CountryId  : System.DBNull.Value;
							
				
					row["Name"] = entity.Name;
							
				
					row["Pin"] = entity.Pin.HasValue ? (object) entity.Pin  : System.DBNull.Value;
							
				
					row["IsActive"] = entity.IsActive.HasValue ? (object) entity.IsActive  : System.DBNull.Value;
							
				
					row["CreatedDate"] = entity.CreatedDate.HasValue ? (object) entity.CreatedDate  : System.DBNull.Value;
							
				
					row["ModifiedDate"] = entity.ModifiedDate.HasValue ? (object) entity.ModifiedDate  : System.DBNull.Value;
							
				
					row["DeletedDate"] = entity.DeletedDate.HasValue ? (object) entity.DeletedDate  : System.DBNull.Value;
							
				
					row["PinCode"] = entity.PinCode;
							
				
				dataTable.Rows.Add(row);
			}		
			
			// send the data to the server		
			bulkCopy.WriteToServer(dataTable);		
			
			// update back the state
//.........这里部分代码省略.........
开发者ID:pratik1988,项目名称:VedicKart,代码行数:101,代码来源:SqlStatesProviderBase.generated.cs


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