本文整理汇总了C#中IDataParameter类的典型用法代码示例。如果您正苦于以下问题:C# IDataParameter类的具体用法?C# IDataParameter怎么用?C# IDataParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IDataParameter类属于命名空间,在下文中一共展示了IDataParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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>();
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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>();
}
示例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;
}
}
示例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;
}
示例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);
}
示例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];
}
示例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;
}
示例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;
}
示例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");
}
示例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;
}
示例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);
}