本文整理汇总了C#中HearbalKartDB.Data.TransactionManager类的典型用法代码示例。如果您正苦于以下问题:C# TransactionManager类的具体用法?C# TransactionManager怎么用?C# TransactionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TransactionManager类属于HearbalKartDB.Data命名空间,在下文中一共展示了TransactionManager类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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 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
示例2: GetByCountryId
/// <summary>
/// Gets rows from the datasource based on the FK_States_Countries key.
/// FK_States_Countries Description:
/// </summary>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="_countryId"></param>
/// <param name="count">out parameter to get total records for query</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of HearbalKartDB.Entities.States objects.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override TList<States> GetByCountryId(TransactionManager transactionManager, System.Int32? _countryId, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_GetByCountryId", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@CountryId", DbType.Int32, _countryId);
IDataReader reader = null;
TList<States> rows = new TList<States>();
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "GetByCountryId", rows));
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
//Create Collection
Fill(reader, rows, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "GetByCountryId", rows));
}
finally
{
if (reader != null)
reader.Close();
commandWrapper = null;
}
return rows;
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:60,代码来源:SqlStatesProviderBase.generated.cs
示例3: GetById
/// <summary>
/// Gets rows from the datasource based on the PK_States index.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="_id"></param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out parameter to get total records for query.</param>
/// <returns>Returns an instance of the <see cref="HearbalKartDB.Entities.States"/> class.</returns>
/// <remarks></remarks>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override HearbalKartDB.Entities.States GetById(TransactionManager transactionManager, System.Int32 _id, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_GetById", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@Id", DbType.Int32, _id);
IDataReader reader = null;
TList<States> tmp = new TList<States>();
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "GetById", tmp));
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
//Create collection and fill
Fill(reader, tmp, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "GetById", tmp));
}
finally
{
if (reader != null)
reader.Close();
commandWrapper = null;
}
if (tmp.Count == 1)
{
return tmp[0];
}
else if (tmp.Count == 0)
{
return null;
}
else
{
throw new DataException("Cannot find the unique instance of the class.");
}
//return rows;
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:73,代码来源:SqlStatesProviderBase.generated.cs
示例4: Find
/// <summary>
/// Returns rows from the DataSource that meet the parameter conditions.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="parameters">A collection of <see cref="SqlFilterParameter"/> objects.</param>
/// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out. The number of rows that match this query.</param>
/// <returns>Returns a typed collection of HearbalKartDB.Entities.States objects.</returns>
public override TList<States> Find(TransactionManager transactionManager, IFilterParameterCollection parameters, string orderBy, int start, int pageLength, out int count)
{
SqlFilterParameterCollection filter = null;
if (parameters == null)
filter = new SqlFilterParameterCollection();
else
filter = parameters.GetParameters();
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_Find_Dynamic", typeof(StatesColumn), filter, orderBy, start, pageLength);
SqlFilterParameter param;
for ( int i = 0; i < filter.Count; i++ )
{
param = filter[i];
database.AddInParameter(commandWrapper, param.Name, param.DbType, param.GetValue());
}
TList<States> rows = new TList<States>();
IDataReader reader = null;
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Find", rows));
if ( transactionManager != null )
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, 0, int.MaxValue);
count = rows.Count;
if ( reader.NextResult() )
{
if ( reader.Read() )
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Find", rows));
}
finally
{
if ( reader != null )
reader.Close();
commandWrapper = null;
}
return rows;
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:71,代码来源:SqlStatesProviderBase.generated.cs
示例5: GetPaged
}//end getall
#endregion
#region GetPaged Methods
/// <summary>
/// Gets a page of rows from the DataSource.
/// </summary>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">Number of rows in the DataSource.</param>
/// <param name="whereClause">Specifies the condition for the rows returned by a query (Name='John Doe', Name='John Doe' AND Id='1', Name='John Doe' OR Id='1').</param>
/// <param name="orderBy">Specifies the sort criteria for the rows in the DataSource (Name ASC; BirthDay DESC, Name ASC);</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of HearbalKartDB.Entities.States objects.</returns>
public override TList<States> GetPaged(TransactionManager transactionManager, string whereClause, string orderBy, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_GetPaged", _useStoredProcedure);
if (commandWrapper.CommandType == CommandType.Text
&& commandWrapper.CommandText != null)
{
commandWrapper.CommandText = commandWrapper.CommandText.Replace(SqlUtil.PAGE_INDEX, string.Concat(SqlUtil.PAGE_INDEX, Guid.NewGuid().ToString("N").Substring(0, 8)));
}
database.AddInParameter(commandWrapper, "@WhereClause", DbType.String, whereClause);
database.AddInParameter(commandWrapper, "@OrderBy", DbType.String, orderBy);
database.AddInParameter(commandWrapper, "@PageIndex", DbType.Int32, start);
database.AddInParameter(commandWrapper, "@PageSize", DbType.Int32, pageLength);
IDataReader reader = null;
//Create Collection
TList<States> rows = new TList<States>();
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "GetPaged", rows));
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, 0, int.MaxValue);
count = rows.Count;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "GetPaged", rows));
}
catch(Exception)
{
throw;
}
finally
{
if (reader != null)
reader.Close();
commandWrapper = null;
}
return rows;
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:81,代码来源:SqlStatesProviderBase.generated.cs
示例6: Insert
/// <summary>
/// Inserts a HearbalKartDB.Entities.ProdTable object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">HearbalKartDB.Entities.ProdTable object to insert.</param>
/// <remarks>
/// After inserting into the datasource, the HearbalKartDB.Entities.ProdTable object will be updated
/// to refelect any changes made by the datasource. (ie: identity or computed columns)
/// </remarks>
/// <returns>Returns true if operation is successful.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Insert(TransactionManager transactionManager, HearbalKartDB.Entities.ProdTable entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.ProdTable_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@Id", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@ItemId", DbType.Int32, (entity.ItemId.HasValue ? (object) entity.ItemId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@CategoryId", DbType.Int32, (entity.CategoryId.HasValue ? (object) entity.CategoryId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@CompanyId", DbType.Int32, (entity.CompanyId.HasValue ? (object) entity.CompanyId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@TypeId", DbType.Int32, (entity.TypeId.HasValue ? (object) entity.TypeId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@SupplementId", DbType.Int32, (entity.SupplementId.HasValue ? (object) entity.SupplementId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@MedicineForId", DbType.Int32, (entity.MedicineForId.HasValue ? (object) entity.MedicineForId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@PurchaseId", DbType.Int32, (entity.PurchaseId.HasValue ? (object) entity.PurchaseId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@SellId", DbType.Int32, (entity.SellId.HasValue ? (object) entity.SellId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@OfferId", DbType.Int32, (entity.OfferId.HasValue ? (object) entity.OfferId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@IsActive", DbType.Boolean, (entity.IsActive.HasValue ? (object) entity.IsActive : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@CreatedDate", DbType.DateTime, (entity.CreatedDate.HasValue ? (object) entity.CreatedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, (entity.ModifiedDate.HasValue ? (object) entity.ModifiedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@DeletedDate", DbType.DateTime, (entity.DeletedDate.HasValue ? (object) entity.DeletedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@ImageUrl", DbType.String, entity.ImageUrl );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _id = database.GetParameterValue(commandWrapper, "@Id");
entity.Id = (System.Int32)_id;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:59,代码来源:SqlProdTableProviderBase.generated.cs
示例7: ExecuteScalar
/// <summary>
/// Executes the scalar.
/// </summary>
/// <param name="transactionManager">The transaction manager.</param>
/// <param name="commandType">Type of the command.</param>
/// <param name="commandText">The command text.</param>
/// <returns></returns>
public override object ExecuteScalar(TransactionManager transactionManager, CommandType commandType, string commandText)
{
Database database = transactionManager.Database;
return database.ExecuteScalar(transactionManager.TransactionObject , commandType, commandText);
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:12,代码来源:SqlNetTiersProvider.cs
示例8: GetAll
/// <summary>
/// Gets All rows from the DataSource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="start">Row number at which to start reading.</param>
/// <param name="pageLength">Number of rows to return.</param>
/// <param name="count">out. The number of rows that match this query.</param>
/// <remarks></remarks>
/// <returns>Returns a typed collection of HearbalKartDB.Entities.Cities objects.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override TList<Cities> GetAll(TransactionManager transactionManager, int start, int pageLength, out int count)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.Cities_Get_List", _useStoredProcedure);
IDataReader reader = null;
//Create Collection
TList<Cities> rows = new TList<Cities>();
try
{
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "GetAll", rows));
if (transactionManager != null)
{
reader = Utility.ExecuteReader(transactionManager, commandWrapper);
}
else
{
reader = Utility.ExecuteReader(database, commandWrapper);
}
Fill(reader, rows, start, pageLength);
count = -1;
if(reader.NextResult())
{
if(reader.Read())
{
count = reader.GetInt32(0);
}
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "GetAll", rows));
}
finally
{
if (reader != null)
reader.Close();
commandWrapper = null;
}
return rows;
}//end getall
开发者ID:pratik1988,项目名称:VedicKart,代码行数:58,代码来源:SqlCitiesProviderBase.generated.cs
示例9: ExecuteNonQuery
/// <summary>
/// Executes the non query.
/// </summary>
/// <param name="transactionManager">The transaction manager.</param>
/// <param name="commandType">Type of the command.</param>
/// <param name="commandText">The command text.</param>
/// <returns></returns>
public override int ExecuteNonQuery(TransactionManager transactionManager, CommandType commandType, string commandText)
{
Database database = transactionManager.Database;
return database.ExecuteNonQuery(transactionManager.TransactionObject , commandType, commandText);
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:12,代码来源:SqlNetTiersProvider.cs
示例10: Insert
/// <summary>
/// Inserts a HearbalKartDB.Entities.States object into the datasource using a transaction.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">HearbalKartDB.Entities.States object to insert.</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>
/// <returns>Returns true if operation is successful.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Insert(TransactionManager transactionManager, HearbalKartDB.Entities.States entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_Insert", _useStoredProcedure);
database.AddOutParameter(commandWrapper, "@Id", DbType.Int32, 4);
database.AddInParameter(commandWrapper, "@CountryId", DbType.Int32, (entity.CountryId.HasValue ? (object) entity.CountryId : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name );
database.AddInParameter(commandWrapper, "@Pin", DbType.Int64, (entity.Pin.HasValue ? (object) entity.Pin : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@IsActive", DbType.Boolean, (entity.IsActive.HasValue ? (object) entity.IsActive : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@CreatedDate", DbType.DateTime, (entity.CreatedDate.HasValue ? (object) entity.CreatedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, (entity.ModifiedDate.HasValue ? (object) entity.ModifiedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@DeletedDate", DbType.DateTime, (entity.DeletedDate.HasValue ? (object) entity.DeletedDate : System.DBNull.Value));
database.AddInParameter(commandWrapper, "@PinCode", DbType.String, entity.PinCode );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Insert", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
object _id = database.GetParameterValue(commandWrapper, "@Id");
entity.Id = (System.Int32)_id;
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Insert", entity));
return Convert.ToBoolean(results);
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:53,代码来源:SqlStatesProviderBase.generated.cs
示例11: Delete
/// <summary>
/// Deletes a row from the DataSource.
/// </summary>
/// <param name="_id">. Primary Key.</param>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <remarks>Deletes based on primary key(s).</remarks>
/// <returns>Returns true if operation suceeded.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Delete(TransactionManager transactionManager, System.Int32 _id)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_Delete", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@Id", DbType.Int32, _id);
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Delete"));
int results = 0;
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
//Stop Tracking Now that it has been updated and persisted.
if (DataRepository.Provider.EnableEntityTracking)
{
string entityKey = EntityLocator.ConstructKeyFromPkItems(typeof(States)
,_id);
EntityManager.StopTracking(entityKey);
}
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Delete"));
commandWrapper = null;
return Convert.ToBoolean(results);
}//end Delete
开发者ID:pratik1988,项目名称:VedicKart,代码行数:46,代码来源:SqlStatesProviderBase.generated.cs
示例12: Update
/// <summary>
/// Update an existing row in the datasource.
/// </summary>
/// <param name="transactionManager"><see cref="TransactionManager"/> object</param>
/// <param name="entity">HearbalKartDB.Entities.States object to update.</param>
/// <remarks>
/// After updating the datasource, the HearbalKartDB.Entities.States object will be updated
/// to refelect any changes made by the datasource. (ie: identity or computed columns)
/// </remarks>
/// <returns>Returns true if operation is successful.</returns>
/// <exception cref="System.Exception">The command could not be executed.</exception>
/// <exception cref="System.Data.DataException">The <paramref name="transactionManager"/> is not open.</exception>
/// <exception cref="System.Data.Common.DbException">The command could not be executed.</exception>
public override bool Update(TransactionManager transactionManager, HearbalKartDB.Entities.States entity)
{
SqlDatabase database = new SqlDatabase(this._connectionString);
DbCommand commandWrapper = StoredProcedureProvider.GetCommandWrapper(database, "dbo.States_Update", _useStoredProcedure);
database.AddInParameter(commandWrapper, "@Id", DbType.Int32, entity.Id );
database.AddInParameter(commandWrapper, "@CountryId", DbType.Int32, (entity.CountryId.HasValue ? (object) entity.CountryId : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@Name", DbType.String, entity.Name );
database.AddInParameter(commandWrapper, "@Pin", DbType.Int64, (entity.Pin.HasValue ? (object) entity.Pin : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@IsActive", DbType.Boolean, (entity.IsActive.HasValue ? (object) entity.IsActive : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@CreatedDate", DbType.DateTime, (entity.CreatedDate.HasValue ? (object) entity.CreatedDate : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@ModifiedDate", DbType.DateTime, (entity.ModifiedDate.HasValue ? (object) entity.ModifiedDate : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@DeletedDate", DbType.DateTime, (entity.DeletedDate.HasValue ? (object) entity.DeletedDate : System.DBNull.Value) );
database.AddInParameter(commandWrapper, "@PinCode", DbType.String, entity.PinCode );
int results = 0;
//Provider Data Requesting Command Event
OnDataRequesting(new CommandEventArgs(commandWrapper, "Update", entity));
if (transactionManager != null)
{
results = Utility.ExecuteNonQuery(transactionManager, commandWrapper);
}
else
{
results = Utility.ExecuteNonQuery(database,commandWrapper);
}
//Stop Tracking Now that it has been updated and persisted.
if (DataRepository.Provider.EnableEntityTracking)
{
EntityManager.StopTracking(entity.EntityTrackingKey);
}
entity.AcceptChanges();
//Provider Data Requested Command Event
OnDataRequested(new CommandEventArgs(commandWrapper, "Update", entity));
return Convert.ToBoolean(results);
}
开发者ID:pratik1988,项目名称:VedicKart,代码行数:56,代码来源:SqlStatesProviderBase.generated.cs
示例13: 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.ProdTable 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.ProdTable> 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 = "ProdTable";
DataTable dataTable = new DataTable();
DataColumn col0 = dataTable.Columns.Add("ID", typeof(System.Int32));
col0.AllowDBNull = false;
DataColumn col1 = dataTable.Columns.Add("ItemID", typeof(System.Int32));
col1.AllowDBNull = true;
DataColumn col2 = dataTable.Columns.Add("CategoryID", typeof(System.Int32));
col2.AllowDBNull = true;
DataColumn col3 = dataTable.Columns.Add("CompanyID", typeof(System.Int32));
col3.AllowDBNull = true;
DataColumn col4 = dataTable.Columns.Add("TypeID", typeof(System.Int32));
col4.AllowDBNull = true;
DataColumn col5 = dataTable.Columns.Add("SupplementID", typeof(System.Int32));
col5.AllowDBNull = true;
DataColumn col6 = dataTable.Columns.Add("MedicineForID", typeof(System.Int32));
col6.AllowDBNull = true;
DataColumn col7 = dataTable.Columns.Add("PurchaseID", typeof(System.Int32));
col7.AllowDBNull = true;
DataColumn col8 = dataTable.Columns.Add("SellID", typeof(System.Int32));
col8.AllowDBNull = true;
DataColumn col9 = dataTable.Columns.Add("OfferID", typeof(System.Int32));
col9.AllowDBNull = true;
DataColumn col10 = dataTable.Columns.Add("IsActive", typeof(System.Boolean));
col10.AllowDBNull = true;
DataColumn col11 = dataTable.Columns.Add("CreatedDate", typeof(System.DateTime));
col11.AllowDBNull = true;
DataColumn col12 = dataTable.Columns.Add("ModifiedDate", typeof(System.DateTime));
col12.AllowDBNull = true;
DataColumn col13 = dataTable.Columns.Add("DeletedDate", typeof(System.DateTime));
col13.AllowDBNull = true;
DataColumn col14 = dataTable.Columns.Add("ImageUrl", typeof(System.String));
col14.AllowDBNull = true;
bulkCopy.ColumnMappings.Add("ID", "ID");
bulkCopy.ColumnMappings.Add("ItemID", "ItemID");
bulkCopy.ColumnMappings.Add("CategoryID", "CategoryID");
bulkCopy.ColumnMappings.Add("CompanyID", "CompanyID");
bulkCopy.ColumnMappings.Add("TypeID", "TypeID");
bulkCopy.ColumnMappings.Add("SupplementID", "SupplementID");
bulkCopy.ColumnMappings.Add("MedicineForID", "MedicineForID");
bulkCopy.ColumnMappings.Add("PurchaseID", "PurchaseID");
bulkCopy.ColumnMappings.Add("SellID", "SellID");
bulkCopy.ColumnMappings.Add("OfferID", "OfferID");
bulkCopy.ColumnMappings.Add("IsActive", "IsActive");
bulkCopy.ColumnMappings.Add("CreatedDate", "CreatedDate");
bulkCopy.ColumnMappings.Add("ModifiedDate", "ModifiedDate");
bulkCopy.ColumnMappings.Add("DeletedDate", "DeletedDate");
bulkCopy.ColumnMappings.Add("ImageUrl", "ImageUrl");
foreach(HearbalKartDB.Entities.ProdTable entity in entities)
{
if (entity.EntityState != EntityState.Added)
continue;
DataRow row = dataTable.NewRow();
row["ID"] = entity.Id;
row["ItemID"] = entity.ItemId.HasValue ? (object) entity.ItemId : System.DBNull.Value;
row["CategoryID"] = entity.CategoryId.HasValue ? (object) entity.CategoryId : System.DBNull.Value;
row["CompanyID"] = entity.CompanyId.HasValue ? (object) entity.CompanyId : System.DBNull.Value;
row["TypeID"] = entity.TypeId.HasValue ? (object) entity.TypeId : System.DBNull.Value;
row["SupplementID"] = entity.SupplementId.HasValue ? (object) entity.SupplementId : System.DBNull.Value;
//.........这里部分代码省略.........
开发者ID:pratik1988,项目名称:VedicKart,代码行数:101,代码来源:SqlProdTableProviderBase.generated.cs
注:本文中的HearbalKartDB.Data.TransactionManager类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论