当前位置: 首页>>代码示例>>C#>>正文


C# SqlQuery.WhereEqual方法代码示例

本文整理汇总了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))
//.........这里部分代码省略.........
开发者ID:volkanceylan,项目名称:Serenity,代码行数:101,代码来源:AuditLogService.cs


注:本文中的Serenity.Data.SqlQuery.WhereEqual方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。