本文整理匯總了C#中Serenity.Data.SqlQuery.WhereEqual方法的典型用法代碼示例。如果您正苦於以下問題:C# SqlQuery.WhereEqual方法的具體用法?C# SqlQuery.WhereEqual怎麽用?C# SqlQuery.WhereEqual使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Serenity.Data.SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.WhereEqual方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: List
public static AuditLogListResponse List(string schema, AuditLogListRequest request)
{
#if COREFX
var fld = Dependency.Resolve<IAuditLogRow>();
#else
var fld = Dependency.Resolve<IAuditLogRow>(schema);
#endif
Authorization.ValidateLoggedIn();
var response = new AuditLogListResponse();
using (var connection = SqlConnections.NewByKey("Default"))
{
response.Entities = new List<Row>();
var row = ((Row)fld).CreateNew();
if (request.Sort == null ||
request.Sort.Length == 0)
request.Sort = new SortBy[] { new SortBy(fld.DateField.Name, true) };
var query = new SqlQuery().From(row)
.Select(
(Field)fld.IdField,
fld.EntityTypeIdField,
fld.EntityIdField,
fld.ParentTypeIdField,
fld.OldParentIdField,
fld.NewParentIdField,
fld.DateField,
(Field)fld.UserIdField,
fld.AuditTypeIdField,
fld.OldAuditDataField,
fld.NewAuditDataField)
.OrderBy(
(Field)fld.IdField)
.ApplySkipTakeAndCount(request.Skip, request.Take, request.ExcludeTotalCount)
.ApplySort(request.Sort);
if (request.EntityTypeId != null &&
request.EntityId != null)
{
var pEntityId = query.AddParam(request.EntityId);
var pEntityTypeId = query.AddParam(request.EntityTypeId);
query.Where(~(
~(
new Criteria(0, fld.EntityTypeIdField) == pEntityTypeId &
new Criteria(0, fld.EntityIdField) == pEntityId) |
~(
new Criteria(0, fld.ParentTypeIdField) == pEntityTypeId &
~(
new Criteria(0, fld.OldParentIdField) == pEntityId |
new Criteria(0, fld.NewParentIdField) == pEntityId))));
}
else
{
if (request.EntityTypeId != null)
query.WhereEqual(fld.EntityTypeIdField, request.EntityTypeId);//Convert.ToInt32(request.EntityTypeId.Value));
if (request.EntityId != null)
query.WhereEqual(fld.EntityIdField, request.EntityId.Value);
}
response.TotalCount = query.ForEach(connection, delegate()
{
response.Entities.Add(row.Clone());
});
response.SetSkipTakeTotal(query);
response.IdNameLookups = new Dictionary<EntityType, Dictionary<long, string>>();
response.FieldTitles = new Dictionary<EntityType, Dictionary<string, string>>();
response.ForeignEntityTypes = new Dictionary<EntityType, Dictionary<string, string>>();
response.EntityTitles = new Dictionary<EntityType, string>();
var lookups = response.IdNameLookups;
var titles = response.FieldTitles;
var foreigns = response.ForeignEntityTypes;
var entities = response.EntityTitles;
Action<EntityType, Int64> addLookup = (entityType, id) => {
Dictionary<long, string> lookup;
if (!lookups.TryGetValue(entityType, out lookup))
{
lookup = new Dictionary<long, string>();
lookups[entityType] = lookup;
}
if (!lookup.ContainsKey(id))
lookup[id] = null;
};
Action<EntityType, string> addTitle = (entityType, field) =>
{
Dictionary<string, string> lookup;
if (!titles.TryGetValue(entityType, out lookup))
//.........這裏部分代碼省略.........