• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Data.Database类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Database类属于Microsoft.Practices.EnterpriseLibrary.Data命名空间,在下文中一共展示了Database类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:32,代码来源:PhotoDAO.cs


示例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;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:27,代码来源:PartialUserDAO.cs


示例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;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:26,代码来源:StudentDAO.cs


示例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;
        }
开发者ID:nirshandileep,项目名称:RHP,代码行数:27,代码来源:PropertyOptionDAO.cs


示例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();
            }
        }
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:30,代码来源:AutoGenerated.cs


示例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;
 }
开发者ID:nirshandileep,项目名称:DairyManager,代码行数:7,代码来源:RoleDAO.cs


示例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;
 }
开发者ID:jerryxi,项目名称:GXP,代码行数:14,代码来源:DBHelper.cs


示例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;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:25,代码来源:TrackDataAccess.cs


示例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();
		}
开发者ID:zesus19,项目名称:c4.v2.T,代码行数:7,代码来源:SMSInfoDA.cs


示例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;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:32,代码来源:CameraIconDataAccess.cs


示例12: GradesDataAccess

		public GradesDataAccess()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			db = DatabaseFactory.CreateDatabase();
		}
开发者ID:zesus19,项目名称:c4.v2.T,代码行数:7,代码来源:GradesDataAccess.cs


示例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);
     }
 }
开发者ID:yujianjob,项目名称:promotion,代码行数:13,代码来源:MSEntLibSqlHelper.cs


示例14: AddParametersFromCache

 protected virtual void AddParametersFromCache(DbCommand command, Database database)
 {
     foreach (IDataParameter parameter in this.cache.GetCachedParameterSet(database.ConnectionString, command))
     {
         command.Parameters.Add(parameter);
     }
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:7,代码来源:ParameterCache.cs


示例15: TransactionDataAccess

		public TransactionDataAccess()
		{
			//
			// TODO: 在此处添加构造函数逻辑
			//
			db = DatabaseFactory.CreateDatabase();
		}
开发者ID:zesus19,项目名称:c4.v2.T,代码行数:7,代码来源:TransactionDataAccess.cs


示例16: Delete

        public static int Delete(Database db, int id)
        {
            try
            {
                StringBuilder sb = new StringBuilder();
                DataSet dataSet = GetVideoInfoById(db, id);
                if (dataSet.Tables[0].Rows.Count == 0)
                {
                    return 0;
                }
                //删除相应的文件
                VideoInfo videoInfo;
                foreach (DataRow dr in dataSet.Tables[0].Rows)
                {

                    videoInfo = new VideoInfo(dr);
                    if (File.Exists(videoInfo.FilePath))
                    {
                        File.Delete(videoInfo.FilePath);
                    }
                }
                //删除出数据库中的记录
                sb.Append("delete from VideoInfo ");
                sb.AppendFormat(" where Id={0}", id);
                string cmdText = sb.ToString();
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:34,代码来源:VideoDataAccess.cs


示例17: CreateReturnParameter

        /// <summary>
        ///     Creates a return parameter and inserts into the command list
        /// </summary>
        /// <param name="db">The database object</param>
        /// <param name="cmd">The command object</param>
        /// <remarks>The DBCommand parameter argument that is modified</remarks>
        public static void CreateReturnParameter(Database db, ref DbCommand cmd)
        {
            #region Defensive

            #region db

            Debug.Assert(db != null, "The argument supplied for parameter 'db' should not be null");

            if(db == null)
            {
                throw new ArgumentNullException("db", "The argument supplied for parameter 'db' should not be null");
            }

            #endregion

            #region cmd

            Debug.Assert(cmd != null, "The argument supplied for parameter 'cmd' should not be null");

            if(cmd == null)
            {
                throw new ArgumentNullException("cmd", "The argument supplied for parameter 'cmd' should not be null");
            }

            #endregion

            #endregion

            db.AddParameter(cmd, RETURN_VALUE, DbType.Int32, sizeof(int), ParameterDirection.ReturnValue,
                    false, 0, 0, string.Empty, DataRowVersion.Default, null);
        }
开发者ID:omprsingh,项目名称:CashCow,代码行数:37,代码来源:SqlUtil.cs


示例18: UpdateWhInfo

 public void UpdateWhInfo(Database db, DbTransaction transaction)
 {
     string sql = "update a set a.wh_name=b.wh_name ,a.wh_code=b.wh_code from wcs_asrv a,wcs_wh b where a.wh_id=b.wh_id and [email protected]";
     DbCommand cmd = db.GetSqlStringCommand(sql);
     db.AddInParameter(cmd, "pKeyValue", DbType.Int32, KeyValue);
     db.ExecuteNonQuery(cmd, transaction);
 }
开发者ID:HeyWeiPan,项目名称:WarehouseControlSystem,代码行数:7,代码来源:WCSAsrv.cs


示例19: Insert

        public static int Insert(Database db, DefaultCardOut defaultCardOut)
        {
            StringBuilder sbField = new StringBuilder();
            StringBuilder sbValue = new StringBuilder();
            sbField.Append("INSERT INTO DefaultCardOut(");
            sbValue.Append("values(");
            sbField.Append("CameraId,");
            sbValue.AppendFormat("{0},", defaultCardOut.CameraId);
            sbField.Append("DisplayChannelId,");
            sbValue.AppendFormat("{0},", defaultCardOut.DisplayChannelId);
            sbField.Append("DispalySplitScreenNo)");
            sbValue.AppendFormat("{0})", defaultCardOut.DisplaySplitScreenNo);

            string cmdText = sbField.ToString() + " " + sbValue.ToString() + "";
            try
            {
                return db.ExecuteNonQuery(CommandType.Text, cmdText);

            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
开发者ID:dalinhuang,项目名称:intvideosurv,代码行数:25,代码来源:DefaultCardOutDataAccess.cs


示例20: BuildDBParameter

 /// <summary>
 /// 加载参数
 /// </summary>
 public static void BuildDBParameter(Database db, DbCommand dbCommand, params SqlParameter[] cmdParms)
 {
     foreach (SqlParameter sp in cmdParms)
     {
         db.AddInParameter(dbCommand, sp.ParameterName, sp.DbType,sp.Value);
     }
 }
开发者ID:GitWPeng,项目名称:Helper,代码行数:10,代码来源:DbHelperSQL2.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Oracle.OracleDatabase类代码示例发布时间:2022-05-26
下一篇:
C# Data.DBCommandWrapper类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap