本文整理汇总了C#中IPredicate.GetSql方法的典型用法代码示例。如果您正苦于以下问题:C# IPredicate.GetSql方法的具体用法?C# IPredicate.GetSql怎么用?C# IPredicate.GetSql使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPredicate
的用法示例。
在下文中一共展示了IPredicate.GetSql方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SelectPaged
public string SelectPaged(IClassMapper classMap, IPredicate predicate, IList<ISort> sort, int page, int resultsPerPage, IDictionary<string, object> parameters)
{
if (sort == null || !sort.Any())
{
throw new ArgumentNullException("Sort", "Sort cannot be null or empty.");
}
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
StringBuilder innerSql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
BuildSelectColumns(classMap),
GetTableName(classMap)));
if (predicate != null)
{
innerSql.Append(" WHERE ")
.Append(predicate.GetSql(this, parameters));
}
string orderBy = sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings();
innerSql.Append(" ORDER BY " + orderBy);
string sql = Configuration.Dialect.GetPagingSql(innerSql.ToString(), page, resultsPerPage, parameters);
return sql;
}
示例2: Count
public string Count(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
{
StringBuilder sql = new StringBuilder(string.Format("SELECT COUNT(*) AS [Total] FROM {0}",
GetTableName(classMap)));
if (predicate != null)
{
sql.Append(" WHERE ")
.Append(predicate.GetSql(parameters));
}
return sql.ToString();
}
示例3: Count
public virtual string Count(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
{
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
var sql = new StringBuilder(string.Format("SELECT COUNT(*) AS {0}Total{1} FROM {2}",
Configuration.Dialect.OpenQuote,
Configuration.Dialect.CloseQuote,
GetTableName(classMap)));
if (predicate != null)
{
sql.Append(" WHERE ")
.Append(predicate.GetSql(this, parameters));
}
return sql.ToString();
}
示例4: Select
public string Select(IClassMapper classMap, IPredicate predicate, IList<ISort> sort, IDictionary<string, object> parameters)
{
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
StringBuilder sql = new StringBuilder(string.Format("SELECT {0} FROM {1}",
BuildSelectColumns(classMap),
GetTableName(classMap)));
if (predicate != null)
{
sql.Append(" WHERE ")
.Append(predicate.GetSql(this, parameters));
}
if (sort != null && sort.Any())
{
sql.Append(" ORDER BY ")
.Append(sort.Select(s => GetColumnName(classMap, s.PropertyName, false) + (s.Ascending ? " ASC" : " DESC")).AppendStrings());
}
return sql.ToString();
}
示例5: Delete
public virtual string Delete(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
{
if (predicate == null)
{
throw new ArgumentNullException("Predicate");
}
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
StringBuilder sql = new StringBuilder(string.Format("DELETE FROM {0}", GetTableName(classMap)));
sql.Append(" WHERE ").Append(predicate.GetSql(this, parameters));
return sql.ToString();
}
示例6: Update
public virtual string Update(IClassMapper classMap, IPredicate predicate, IDictionary<string, object> parameters)
{
if (predicate == null)
{
throw new ArgumentNullException("Predicate");
}
if (parameters == null)
{
throw new ArgumentNullException("Parameters");
}
var columns = classMap.Properties.Where(p => !(p.Ignored || p.IsReadOnly || p.KeyType == KeyType.Identity));
if (!columns.Any())
{
throw new ArgumentException("No columns were mapped.");
}
var setSql =
columns.Select(
p =>
string.Format(
"{0} = {1}{2}", GetColumnName(classMap, p, false), Configuration.Dialect.ParameterPrefix, p.Name));
return string.Format("UPDATE {0} SET {1} WHERE {2}",
GetTableName(classMap),
setSql.AppendStrings(),
predicate.GetSql(this, parameters));
}
示例7: Delete
public string Delete(IClassMapper classMap, IPredicate predicate = null, IDictionary<string, object> parameters = null)
{
StringBuilder sql = new StringBuilder(string.Format("DELETE FROM {0}", GetTableName(classMap)));
if (predicate != null && parameters != null)
sql.Append(" WHERE ").Append(predicate.GetSql(this, parameters));
return sql.ToString();
}