本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database类的典型用法代码示例。如果您正苦于以下问题:C# Database类的具体用法?C# Database怎么用?C# Database使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Database类属于Microsoft.Practices.EnterpriseLibrary.Data命名空间,在下文中一共展示了Database类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Insert
public bool Insert(Photo photo, Database db, DbTransaction transaction = null)
{
DbCommand command = db.GetStoredProcCommand("usp_PhotoInsert");
photo.PhotoId = Guid.NewGuid();
db.AddInParameter(command, "PhotoId", DbType.Guid, photo.PhotoId);
db.AddInParameter(command, "FileName", DbType.String, photo.FileName);
db.AddInParameter(command, "FilePath", DbType.String, photo.FilePath);
db.AddInParameter(command, "ContextId", DbType.Guid, photo.ContextId);
db.AddInParameter(command, "Description", DbType.String, photo.Description);
db.AddInParameter(command, "ContextTypeId", DbType.Int32, (int)photo.ContextType);
db.AddInParameter(command, "ContextSubTypeId", DbType.Int32, photo.ContextSubTypeId);
db.AddInParameter(command, "PhotoCategoryId", DbType.Int32, (int)photo.PhotoCategory);
db.AddInParameter(command, "IsDeleted", DbType.String, photo.IsDeleted);
db.AddInParameter(command, "CreatedBy", DbType.Guid, photo.CreatedBy);
db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);
if (transaction == null)
{
db.ExecuteNonQuery(command);
}
else
{
db.ExecuteNonQuery(command, transaction);
}
photo.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
photo.UpdatedDate = photo.CreatedDate;
return true;
}
示例2: Insert
public bool Insert(PartialUser partialUser, Database db, DbTransaction transaction)
{
DbCommand command = db.GetStoredProcCommand("usp_PartialUserInsert");
partialUser.PartialUserId = Guid.NewGuid();
db.AddInParameter(command, "PartialUserId", DbType.Guid, partialUser.PartialUserId);
db.AddInParameter(command, "Email", DbType.String, partialUser.Email);
db.AddInParameter(command, "FirstName", DbType.String, partialUser.FirstName);
db.AddInParameter(command, "MiddleName", DbType.String, partialUser.MiddleName);
db.AddInParameter(command, "LastName", DbType.String, partialUser.LastName);
db.AddInParameter(command, "Contact", DbType.String, partialUser.Contact);
db.AddInParameter(command, "RoleId", DbType.Guid, partialUser.RoleId);
db.AddInParameter(command, "UserId", DbType.Guid, partialUser.UserId);
db.AddInParameter(command, "PartialHouseId", DbType.Guid, partialUser.PartialHouseId);
db.AddInParameter(command, "IsDeleted", DbType.Boolean, partialUser.IsDeleted);
db.AddInParameter(command, "CreatedBy", DbType.Guid, partialUser.CreatedBy);
db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);
db.ExecuteNonQuery(command, transaction);
partialUser.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
partialUser.UpdatedDate = partialUser.CreatedDate;
return true;
}
示例3: Insert
public bool Insert(Student student, Database db, DbTransaction transaction)
{
DbCommand command = db.GetStoredProcCommand("usp_StudentInsert");
db.AddInParameter(command, "StudentId", DbType.Guid, Guid.NewGuid());
db.AddInParameter(command, "UserId", DbType.Guid, student.StudentUser.UserId);
db.AddInParameter(command, "SchoolId", DbType.Guid, student.School.SchoolId);
db.AddInParameter(command, "IsDeleted", DbType.Boolean, student.IsDeleted);
db.AddInParameter(command, "Year", DbType.String, student.School.Year);
db.AddInParameter(command, "StartYear", DbType.String, student.StartYear);
db.AddInParameter(command, "StartMonth", DbType.String, student.StartMonth);
db.AddInParameter(command, "Status", DbType.String, student.Status);
db.AddInParameter(command, "PreviousSchoolInfo", DbType.String, student.PreviousSchoolInfo);
db.AddInParameter(command, "PreviousSchool", DbType.String, student.PreviousSchool);
db.AddInParameter(command, "MajorId", DbType.Int16, student.MajorId);
db.AddInParameter(command, "CreatedBy", DbType.Guid, student.CreatedBy);
db.AddOutParameter(command, "CreatedDate", DbType.DateTime, 30);
db.ExecuteNonQuery(command, transaction);
student.CreatedDate = Convert.ToDateTime(db.GetParameterValue(command, "CreatedDate").ToString());
student.UpdatedDate = student.CreatedDate;
return true;
}
示例4: Insert
public bool Insert(Option Option, Database db, DbTransaction transaction)
{
DbCommand command = db.GetStoredProcCommand("usp_OptionInsert");
db.AddInParameter(command, "Name", DbType.String, Option.Name);
db.AddInParameter(command, "Description", DbType.String, Option.Description);
db.AddInParameter(command, "OptionCategoryId", DbType.Int16, Option.OptionCategoryId);
db.AddInParameter(command, "ParentOptionId", DbType.Int16, Option.ParentOptionId);
db.AddInParameter(command, "IsDeleted", DbType.Boolean, Option.IsDeleted);
db.AddInParameter(command, "IsMultiSelect", DbType.Boolean, Option.IsMultiSelect);
db.AddInParameter(command, "Points", DbType.Int16, Option.Points);
db.AddOutParameter(command, "OptionId", DbType.Int16, 3);
if (transaction == null)
{
db.ExecuteNonQuery(command);
}
else
{
db.ExecuteNonQuery(command, transaction);
}
Option.OptionId = Convert.ToInt16(db.GetParameterValue(command, "OptionId").ToString());
return true;
}
示例5: Admin1
/// <summary>
/// Instanciates a Admin1 object from the database via the admin1ID
/// </summary>
public Admin1(int admin1ID)
{
db = DatabaseFactory.CreateDatabase();
DbCommand dbCommand = db.GetStoredProcCommand("AG_GetAdmin1Byadmin1ID");
db.AddInParameter(dbCommand, "admin1ID", DbType.Int32, admin1ID);
//execute the stored procedure
using (IDataReader dr = db.ExecuteReader(dbCommand))
{
ColumnFieldList list = new ColumnFieldList(dr);
if (dr.Read())
{
if (list.IsColumnPresent("admin1ID")) { this._admin1ID = (int)dr["admin1ID"]; }
if (list.IsColumnPresent("CountryID")) { this._countryID = (int)dr["CountryID"]; }
if (list.IsColumnPresent("admin1CD")) { this._admin1CD = (string)dr["admin1CD"]; }
if (list.IsColumnPresent("Name")) { this._name = (string)dr["Name"]; }
}
else
{
throw new Exception("There is no Admin1 in the database with the ID " + admin1ID);
}
dr.Close();
}
}
示例6: DeleteRoleRightsByRoleId
public bool DeleteRoleRightsByRoleId(Role roles, Database db, DbTransaction transaction)
{
DbCommand dbCommand = db.GetStoredProcCommand("usp_RoleRightDelete");
db.AddInParameter(dbCommand, "RoleId", DbType.Guid, roles.RoleId);
db.ExecuteNonQuery(dbCommand, transaction);
return true;
}
示例7: ExecuteDataSet
/// <summary>
/// 获取一个DataSet数据集
/// </summary>
/// <param name="cmdType">命令类型,SQL文本或存储过程</param>
/// <param name="cmdText">SQL语句或存储过程名称</param>
/// <param name="paras">查询参数</param>
/// <returns>DataSet数据集</returns>
public static DataSet ExecuteDataSet(Database db, DbTransaction dbTransaction, CommandType cmdType, string cmdText, params DbParameter[] paras)
{
DbCommand dbcmd = GetDbCommand(db, cmdType, cmdText);
PrepareDbCommand(dbcmd, paras);
DataSet ds = db.ExecuteDataSet(dbcmd, dbTransaction);
return ds;
}
示例8: Insert
public static int Insert(Database db, Track oTrack)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO [Track](");
sbValue.Append("values (");
//sbField.Append("[Id]");
//sbValue.AppendFormat("'{0}'", oTrack.Id);
sbField.Append("[REct])");
sbValue.AppendFormat("'{0}')", oTrack.REct);
string cmdText = sbField.ToString() + " " + sbValue.ToString();
try
{
cmdText = cmdText.Replace("\r\n", "");
db.ExecuteNonQuery(CommandType.Text, cmdText);
int id = int.Parse(db.ExecuteScalar(CommandType.Text, "SELECT ident_current('Track')").ToString());
return id;
}
catch (Exception ex)
{
throw ex;
}
}
示例9: SetUp
public void SetUp()
{
EnvironmentHelper.AssertOracleClientIsInstalled();
DatabaseProviderFactory factory = new DatabaseProviderFactory(OracleTestConfigurationSource.CreateConfigurationSource());
db = factory.Create("OracleTest");
CreateStoredProcedure();
}
开发者ID:VAllens,项目名称:EntLibContrib.Data.Oracle.ManagedDataAccess,代码行数:7,代码来源:OracleParameterFixture.cs
示例10: SMSInfoDA
public SMSInfoDA()
{
//
// TODO: 在此处添加构造函数逻辑
//
db = DatabaseFactory.CreateDatabase();
}
示例11: Insert
public static int Insert(Database db, CameraIconInfo cameraIconInfo)
{
StringBuilder sbField = new StringBuilder();
StringBuilder sbValue = new StringBuilder();
sbField.Append("INSERT INTO CameraIconInfo(");
sbValue.Append("values(");
sbField.Append("CameraId");
sbValue.AppendFormat("{0}", cameraIconInfo.CameraId);
sbField.Append(",IconIndex");
sbValue.AppendFormat(",{0}", cameraIconInfo.IconIndex);
sbField.Append(",ToolTip");
sbValue.AppendFormat(",'{0}'", cameraIconInfo.ToolTip);
sbField.Append(",X");
sbValue.AppendFormat(",{0}", cameraIconInfo.X);
sbField.Append(",Y");
sbValue.AppendFormat(",{0}", cameraIconInfo.Y);
sbField.Append(",Map");
sbValue.AppendFormat(",{0}", cameraIconInfo.Map);
sbField.Append(",MatchAlarmId)");
sbValue.AppendFormat(",{0})", cameraIconInfo.MatchAlarmId);
string cmdText = sbField + " " + sbValue;
try
{
return db.ExecuteNonQuery(CommandType.Text, cmdText);
}
catch (Exception ex)
{
throw ex;
}
}
示例12: GradesDataAccess
public GradesDataAccess()
{
//
// TODO: 在此处添加构造函数逻辑
//
db = DatabaseFactory.CreateDatabase();
}
示例13: BuildDBParameterForReturnValue
/// <summary>
/// 为储存过程加载输出变量参数
/// </summary>
/// <param name="db">database</param>
/// <param name="dbCommand">db command</param>
/// <param name="cmdParms">参数数组</param>
public static void BuildDBParameterForReturnValue(Database db, DbCommand dbCommand, params IDataParameter[] cmdParms)
{
foreach (SqlParameter sp in cmdParms)
{
db.AddParameter(dbCommand, sp.ParameterName, sp.DbType, sp.Size, ParameterDirection.Output, false, 0, 0, sp.SourceColumn, DataRowVersion.Current, DBNull.Value);
}
}
示例14: AddParametersFromCache
protected virtual void AddParametersFromCache(DbCommand command, Database database)
{
foreach (IDataParameter parameter in this.cache.GetCachedParameterSet(database.ConnectionString, command))
{
command.Parameters.Add(parameter);
}
}
示例15: TransactionDataAccess
public TransactionDataAccess()
{
//
// TODO: 在此处添加构造函数逻辑
//
db = DatabaseFactory.CreateDatabase();
}