本文整理匯總了C#中Serenity.Data.SqlQuery.Select方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlQuery.Select方法的具體用法?C# SqlQuery.Select怎麽用?C# SqlQuery.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Serenity.Data.SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.Select方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPrepareQuery
public override void OnPrepareQuery(ISaveRequestHandler handler, SqlQuery query)
{
base.OnPrepareQuery(handler, query);
if (this.replaceFields != null)
{
foreach (var field in replaceFields.Values)
{
if (!field.IsTableField() &&
(!(query is ISqlQueryExtensible) ||
((ISqlQueryExtensible)query).GetSelectIntoIndex(field) <= 0))
query.Select(field);
}
}
}
示例2: ProcessReplaceFields
internal static string ProcessReplaceFields(string s, Dictionary<string, Field> replaceFields, ISaveRequestHandler handler)
{
if (replaceFields == null)
return s;
var row = handler.Row;
// foreign / calculated fields might not be available yet in new row
// so load them from database
// TODO: if referenced foreign fields changed on update,
// values might be wrong in before update where we set filename
// so need to handle update in AfterSave just like create
if (handler.IsCreate &&
replaceFields.Values.Any(x => !x.IsTableField()))
{
var idField = (Field)(((IIdRow)handler.Row).IdField);
row = handler.Row.Clone();
var query = new SqlQuery()
.From(row);
foreach (var field in replaceFields.Values)
query.Select(field);
query.Where(idField == new ValueCriteria(idField.AsObject(row)));
query.GetFirst(handler.Connection);
}
foreach (var p in replaceFields)
{
var val = p.Value.AsObject(row);
string str;
var colon = p.Key.IndexOf(":");
if (colon >= 0)
str = String.Format("{0:" + p.Key.Substring(colon + 1, p.Key.Length - colon - 2) + "}", val);
else
str = Convert.ToString(val ?? "", CultureInfo.InvariantCulture);
str = StringHelper.SanitizeFilename(str).Replace('\\', '_').Replace("..", "_");
if (string.IsNullOrWhiteSpace(str))
str = "_";
while (str.EndsWith("."))
str = str.Substring(0, str.Length - 1) + "_";
s = s.Replace(p.Key, str);
}
while (s.IndexOf("//") > 0)
s = s.Replace("//", "/_/");
return s;
}