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

C# IDataParameter类代码示例

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

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



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

示例1: RetrieveNewLowExchangeAmount

        public IList<StockPriceHistory> RetrieveNewLowExchangeAmount(DateTime exchangeDate, int backDays = 10)
        {
            var exchangeDates = this._exchangeDayRepository.RetrieveLatestExchangeDaysBeforeOneDay(exchangeDate, backDays);

            if (exchangeDates.Count == 0)
            {
                return new List<StockPriceHistory>();
            }

            var beginDate = exchangeDates.Min(x => x.Date);
            var endDate = exchangeDates.Max(x => x.Date);

            var sql = @"select * from stockpricehistory as ta inner join
                                                                (
                                                                    select code, min(exchangeamountinrmb) as minrmb
                                                                    from stockpricehistory
                                                                    where date >= @begindate and date <= @enddate and exchangeamountinrmb > 0
                                                                    group by code
                                                                ) as tb
                                                                on ta.code = tb.code
                                                                where ta.date = @exchangedate and ta.exchangeamountinrmb > 0 and ta.exchangeamountinrmb <= tb.minrmb;";

            var parameters = new IDataParameter[]
            {
                new MySqlParameter("@begindate", beginDate.ToString(Setting.Date_Format_4y_2M_2d)),
                new MySqlParameter("@enddate", endDate.ToString(Setting.Date_Format_4y_2M_2d)),
                new MySqlParameter("@exchangedate", exchangeDate.ToString(Setting.Date_Format_4y_2M_2d))
            };
            var table = this.DbRequest.RetrieveTable(this.ConnectionString, sql, parameters, CommandType.Text);

            return table.ToModel<StockPriceHistory>();
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:32,代码来源:ExchangeStrategy.cs


示例2: BuildQueryCommand

        /// <summary>
        /// 构建 SqlCommand 对象(用来返回一个结果集,而不是一个整数值)
        /// </summary>
        /// <param name="connection">数据库连接</param>
        /// <param name="storedProcName">存储过程名</param>
        /// <param name="parameters">存储过程参数</param>
        /// <returns>SqlCommand</returns>
        public static SqlCommand BuildQueryCommand(SqlConnection connection, string storedProcName, IDataParameter[] parameters)
        {
            SqlCommand command = new SqlCommand(storedProcName, connection);
            command.CommandType = CommandType.StoredProcedure;

            /*
             * 修改点(刘强)
             * 当要执行的存储过程没有参数时,这里会报错,所以加了一个if判断,判断parameters不为空时,才去执行foreach
             * **/
            if (parameters != null)
            {
                foreach (SqlParameter parameter in parameters)
                {
                    if (parameter != null)
                    {
                        // 检查未分配值的输出参数,将其分配以DBNull.Value.
                        if ((parameter.Direction == ParameterDirection.InputOutput || parameter.Direction == ParameterDirection.Input) &&
                            (parameter.Value == null))
                        {
                            parameter.Value = DBNull.Value;
                        }
                        command.Parameters.Add(parameter);
                    }
                }
            }

            return command;
        }
开发者ID:refinedKing,项目名称:WeiXin--Vs2010-,代码行数:35,代码来源:SqlServerHelper.cs


示例3: TryGetCart

 internal static Boolean TryGetCart(String Emplid, out List<ShopCartItem> result, out Exception error)
 {
     result = new List<ShopCartItem>();
     error = null;
     try
     {
         using (DataWorker dw = DataWorkerFactory.CreateDataWorker("RDSDB"))
         {
             IDataParameter[] args = new IDataParameter[]{
                 dw.NewParameter("EMPLID", Emplid)
             };
             DataTable dt = dw.ExecuteDataTable("PWEATHERBY.SHOP_CART.GetCart", CommandType.StoredProcedure, ref args);
             foreach (DataRow dr in dt.Rows)
             {
                 ShopCartItem item = new ShopCartItem();
                 item.Term = Convert.ToString(dr["TERM"]);
                 item.SessionGroup = Convert.ToString(dr["SESSION_GROUP"]);
                 item.CourseID = Convert.ToString(dr["COURSE_ID"]);
                 item.CourseOfferNbr = Convert.ToString(dr["COURSE_OFFER_NBR"]);
                 item.Subject = Convert.ToString(dr["SUBJECT"]);
                 item.ClassNumber = Convert.ToString(dr["CLASS_NUMBER"]);
                 item.ClassSection = Convert.ToString(dr["CLASS_SECTION"]);
                 item.RegistrationNbr = Convert.ToString(dr["REGISTRATION_NBR"]);
                 result.Add(item);
             }
             return true;
         }
     }
     catch (Exception e)
     {
         error = e;
     }
     return false;
 }
开发者ID:pweatherby,项目名称:csci567,代码行数:34,代码来源:ShopCartDataManager.cs


示例4: ExecuteDataReaderByStoredProc

 public static IDataReader ExecuteDataReaderByStoredProc(string storedProcName, IDataParameter[] cmdParms, params IDataParameter[] cmdOutputParms)
 {
     DbCommand dbCommand = db.GetStoredProcCommand(storedProcName);
     BuildDBParameter(db, dbCommand, cmdParms);
     BuildDBParameterForReturnValue(db, dbCommand, cmdOutputParms);
     return db.ExecuteReader(dbCommand);
 }
开发者ID:yujianjob,项目名称:promotion,代码行数:7,代码来源:MSEntLibSqlHelper.cs


示例5: CreateParameterCopy

 private static IDataParameter[] CreateParameterCopy(DbCommand command)
 {
     IDataParameterCollection parameters = command.Parameters;
     IDataParameter[] array = new IDataParameter[parameters.Count];
     parameters.CopyTo(array, 0);
     return CachingMechanism.CloneParameters(array);
 }
开发者ID:huaminglee,项目名称:myyyyshop,代码行数:7,代码来源:ParameterCache.cs


示例6: RetrieveByStock

 public IList<StockSeasonReport> RetrieveByStock(string stockCode)
 {
     var sql = @"select a.*, b.name from stock_season_report a inner join marketstock b on a.code = b.code where a.code = @code order by a.reportday desc;";
     var parameters = new IDataParameter[] { new MySqlParameter("@code", stockCode) };
     var table = this.DbRequest.RetrieveTable(this.ConnectionString, sql, parameters, CommandType.Text);
     return table.ToModel<StockSeasonReport>();
 }
开发者ID:wbqsln,项目名称:HitStock,代码行数:7,代码来源:StockSeasonReportRepository.cs


示例7: OnMapParameter

 protected override void OnMapParameter(IDataParameter input, IDataParameter output)
 {
     if (input.DbType == DbType.String && ((string)input.Value).Length > 4000)
     {
         ((SqlCeParameter)output).SqlDbType = SqlDbType.NText;
     }
 }
开发者ID:jamietre,项目名称:IQMap,代码行数:7,代码来源:SQLCompactEditionController.cs


示例8: AddParameterSetToCache

 /// <devdoc>
 /// Add a parameter array to the cache for the command.
 /// </devdoc>        
 public void AddParameterSetToCache(IDbCommand command, IDataParameter[] parameters)
 {
     string connectionString = command.Connection.ConnectionString;
     string storedProcedure = command.CommandText;
     string key = CreateHashKey(connectionString, storedProcedure);
     this.paramCache[key] = parameters;
 }
开发者ID:bnantz,项目名称:NCS-V1-1,代码行数:10,代码来源:CachingMechanism.cs


示例9: Create

        public void Create(StockPriceHistory entity)
        {
            var sql = @"insert into stockpricehistory(openprice,price,highestprice,lowestprice,ceilingprice,floorprice,yesterdaycloseprice,pricechangepercent,priceshakepercent,exchangerate,exchangeamountinhands,exchangeamountinrmb,pe,pb,flowablemarketvalue,totalmarketvalue,createtime,updatetime,code,name,date) values(@openprice,@price,@highestprice,@lowestprice,@ceilingprice,@floorprice,@yesterdaycloseprice,@pricechangepercent,@priceshakepercent,@exchangerate,@exchangeamountinhands,@exchangeamountinrmb,@pe,@pb,@flowablemarketvalue,@totalmarketvalue,@createtime,@updatetime,@code,@name,@date);";
            var parameters = new IDataParameter[]
            {
                new MySqlParameter("@openprice",entity.OpenPrice),
                new MySqlParameter("@price",entity.Price),
                new MySqlParameter("@highestprice",entity.HighestPrice),
                new MySqlParameter("@lowestprice",entity.LowestPrice),
                new MySqlParameter("@ceilingprice",entity.CeilingPrice),
                new MySqlParameter("@floorprice",entity.FloorPrice),
                new MySqlParameter("@yesterdaycloseprice",entity.YesterdayClosePrice),
                new MySqlParameter("@pricechangepercent",entity.PriceChangePercent),
                new MySqlParameter("@priceshakepercent",entity.PriceShakePercent),
                new MySqlParameter("@exchangerate",entity.ExchangeRate),
                new MySqlParameter("@exchangeamountinhands",entity.ExchangeAmountInHands),
                new MySqlParameter("@exchangeamountinrmb",entity.ExchangeAmountInRMB),
                new MySqlParameter("@pe",entity.PE),
                new MySqlParameter("@pb",entity.PB),
                new MySqlParameter("@flowablemarketvalue",entity.FlowableMarketValue),
                new MySqlParameter("@totalmarketvalue",entity.TotalMarketValue),
                new MySqlParameter("@createtime",DateTime.Now),
                new MySqlParameter("@updatetime",DateTime.Now),
                new MySqlParameter("@code",entity.Code),
                new MySqlParameter("@name",entity.Name),
                new MySqlParameter("@date",entity.Date.ToString("yyyy-MM-dd"))
            };

            this.DbRequest.ExecuteNonQuery(this.ConnectionString, sql, parameters, CommandType.Text);
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:30,代码来源:StockPriceHistoryRepository.cs


示例10: CommandStruct

 /// <summary>
 /// 
 /// </summary>
 /// <param name="tableName"></param>
 /// <param name="editType"></param>
 public CommandStruct(string tableName, CommandMode editType)
 {
     TableName = tableName;
     EntityType = editType;
     Filter = new CommandFilter();
     Parameters = new IDataParameter[0];
 }
开发者ID:0jpq0,项目名称:Scut,代码行数:12,代码来源:CommandStruct.cs


示例11: ExcuteDataTableByTextWithTrans

        public static DataTable ExcuteDataTableByTextWithTrans(SqlConnection connection, SqlTransaction tran, string sqlText, IDataParameter[] paramers)
        {
            DataTable dt = new DataTable("");
            if (connection.State != ConnectionState.Open)
            {
                connection.Open();
            }

            SqlCommand cmd = new SqlCommand(sqlText, connection, tran);
            cmd.CommandTimeout = 300;
            cmd.CommandType = CommandType.Text;
            if (null != paramers)
            {
                foreach (SqlParameter param in paramers)
                {
                    cmd.Parameters.Add(param);
                }
            }

            ////Add parameter to receive return value of stored procedure
            //SqlParameter pr = new SqlParameter("ReturnValue", SqlDbType.Int);
            //pr.Direction = ParameterDirection.ReturnValue;
            //cmd.Parameters.Add(pr);

            SqlDataAdapter ada = new SqlDataAdapter(cmd);
            ada.Fill(dt);

            return dt;
            //return pr.Value;
        }
开发者ID:SiberianMark,项目名称:WebServiceDocNet,代码行数:30,代码来源:SqlHelper.cs


示例12: GetByNodeId

        /// <summary>
        /// 获取指定节点下的信息的集合,并显示在数据页中。
        /// </summary>
        /// <param name="nodeId">节点Id。</param>
        /// <param name="isAdmin">是否是管理后台。</param>
        /// <param name="pageIndex">要返回的结果页的索引。pageIndex 从零开始。</param>
        /// <param name="pageSize">要返回的结果页的大小。</param>
        /// <param name="totalRecords">匹配的结果总数。</param>
        /// <returns>包含一页 pageSize InfoEntity 对象的 List 集合,这些对象从 pageIndex 指定的页开始。</returns>
        public virtual List<InfoEntity> GetByNodeId(int nodeId, bool isAdmin, int pageIndex, int pageSize, out int totalRecords)
        {
            Contract.Requires(nodeId > 0);
            Contract.Requires(pageIndex > 0);
            Contract.Requires(pageSize > 0);

            IDataParameter[] parameters = new IDataParameter[5];

            parameters[0] = this.db.NewDataParameter("@NodeId", "%" + nodeId.ToString() + "%");
            parameters[1] = this.db.NewDataParameter("@PageIndex", pageIndex);
            parameters[2] = this.db.NewDataParameter("@PageSize", pageSize);
            parameters[3] = this.db.NewDataParameter("@IsAdmin", isAdmin);
            parameters[4] = this.db.NewOutputDataParameter("@Count");
            parameters[4].DbType = DbType.Int32;

            List<InfoEntity> infos = new List<InfoEntity>(pageSize);

            using (IDataReader reader = this.db.ExcuteReader(CommandType.StoredProcedure, "EF_Info_GetByNodeId", parameters))
            {
                while (reader.Read())
                {
                    InfoEntity info = this.PopulateInfo(reader);
                    infos.Add(info);
                }
            }

            totalRecords = (int)this.db.GetOutputDataParameter("@Count").Value;

            return infos;
        }
开发者ID:adamchuan,项目名称:eFramework,代码行数:39,代码来源:InfoManager.cs


示例13: AddBusType

 public int AddBusType(String Name,String Description)
 {
     IDataParameter[] idp=new IDataParameter[5];
     idp[0] = createParameter("@Name", Name);
     idp[1] = createParameter("@Description", Description);
     return ExecuteNonQuery("InsertBusTpye");
 }
开发者ID:12130157,项目名称:onlinebusticketreseverationsystem1,代码行数:7,代码来源:BusTypeAccessData.cs


示例14: IsXmlParameter

		/// <summary>
		/// Determines if a parameter is an XML type parameter.
		/// </summary>
		/// <param name="command">The related command object.</param>
		/// <param name="parameter">The parameter to test.</param>
		/// <returns>True if the parameter is an XML parameter.</returns>
		public override bool IsXmlParameter(IDbCommand command, IDataParameter parameter)
		{
			if (parameter == null) throw new ArgumentNullException("parameter");

			var op = (OracleParameter)parameter;
			return op.OracleDbType == OracleDbType.XmlType;
		}
开发者ID:EdWeller,项目名称:Insight.Database,代码行数:13,代码来源:OracleInsightDbProvider.cs


示例15: GetParameterSpecifier

        public static string GetParameterSpecifier(this IProviderMetadata metadata, IDataParameter parameter)
        {
            if (parameter == null) throw new ArgumentNullException("parameter");
            if (!parameter.ParameterName.StartsWith("@", StringComparison.Ordinal)) throw new ArgumentException("Parameter names must start with an '@'.");

            string name = parameter.ParameterName.Substring(1); // the name itself starts after the @
            return metadata.ParameterExpression.Replace("p", name);
        }
开发者ID:nachojammers,项目名称:MigSharp,代码行数:8,代码来源:IProviderMetaData.cs


示例16: Retrieve

        public MarketStock Retrieve(string stockCode)
        {
            var sql = @"select * from marketstock where code = @code;";
            var parameters = new IDataParameter[] { new MySqlParameter("@code", stockCode) };
            var table = this.DbRequest.RetrieveTable(this.ConnectionString, sql, parameters, CommandType.Text);

            return table.Rows.Count == 0 ? null : table.Rows[0].ToModel<MarketStock>();
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:8,代码来源:MarketStockRepository.cs


示例17: Retrieve

 public SelfStockGroup Retrieve(int stockGroupId)
 {
     var parameters = new IDataParameter[]
     {
         new MySqlParameter("@P_ID", stockGroupId)
     };
     return this.DbRequest.RetrieveTable(this.ConnectionString, "P_STOCK_GROUP_GET", parameters).ToModel<SelfStockGroup>().FirstOrDefault();
 }
开发者ID:wbqsln,项目名称:HitStock,代码行数:8,代码来源:StockGroupRepository.cs


示例18: RetrieveByUserName

        public User RetrieveByUserName(string userName)
        {
            var sql = @"select * from user where username= @username and disabled = 0;";
            var parameters = new IDataParameter[] { new MySqlParameter("@username", userName) };
            var table = this.DbRequest.RetrieveTable(this.ConnectionString, sql, parameters, CommandType.Text);

            return table.Rows.Count == 0 ? null : table.Rows[0].ToModel<User>();
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:8,代码来源:UserRepository.cs


示例19: GetPersonalFilters

        public IList<Filter> GetPersonalFilters(int userId)
        {
            var sql = @"select * from filter where userid = @userid;";
            var parameters = new IDataParameter[] { new MySqlParameter("@userid", userId) };
            var table = this.DbRequest.RetrieveTable(this.ConnectionString, sql, parameters, CommandType.Text);

            return table.ToModel<Filter>();
        }
开发者ID:wbqsln,项目名称:HitStock,代码行数:8,代码来源:FilterRepository.cs


示例20: ExecuteSingle

 public virtual object ExecuteSingle(string sql, IDataParameter[] parameters)
 {
     CheckConnection();
     using (SqlCommand cmd = new SqlCommand(sql, Connection))
     {
         return cmd.ExecuteScalar();
     }
 }
开发者ID:AimilaGaven,项目名称:Magic,代码行数:8,代码来源:DataAccess.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# IDataProvider类代码示例发布时间:2022-05-24
下一篇:
C# IDataObject类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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