本文整理汇总了C#中Gentle.Framework.SqlBuilder.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# SqlBuilder.AddParameter方法的具体用法?C# SqlBuilder.AddParameter怎么用?C# SqlBuilder.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gentle.Framework.SqlBuilder
的用法示例。
在下文中一共展示了SqlBuilder.AddParameter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RetrieveWorkingDays
public static IList<Program> RetrieveWorkingDays(DateTime startTime, DateTime endTime, int channelId, int maxDays)
{
SqlBuilder sb = new SqlBuilder(StatementType.Select, typeof (Program));
// where foreigntable.foreignkey = ourprimarykey
sb.AddConstraint(Operator.GreaterThanOrEquals, "endTime", DateTime.Now /*startTime*/);
if (maxDays > 0)
{
sb.AddConstraint(Operator.LessThan, "startTime", DateTime.Now.AddDays(maxDays));
}
sb.AddConstraint(Operator.Equals, "idChannel", channelId);
sb.AddParameter("pStartTime", typeof (DateTime));
sb.AddParameter("pEndTime", typeof (DateTime));
AddTimeRangeConstraint(sb, "startTime", "endTime", "pStartTime", "pEndTime", (endTime.Day != startTime.Day));
AddWorkingDaysConstraint(sb, "startTime");
// passing true indicates that we'd like a list of elements, i.e. that no primary key
// constraints from the type being retrieved should be added to the statement
SqlStatement stmt = sb.GetStatement(true);
stmt.SetParameter("pStartTime", startTime);
stmt.SetParameter("pEndTime", endTime);
// execute the statement/query and create a collection of User instances from the result set
return ObjectFactory.GetCollection<Program>(stmt.Execute());
}