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


C# IRepository.AsQueryable方法代码示例

本文整理汇总了C#中IRepository.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.AsQueryable方法的具体用法?C# IRepository.AsQueryable怎么用?C# IRepository.AsQueryable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IRepository的用法示例。


在下文中一共展示了IRepository.AsQueryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CheckIsUsed

        public IFutureValue<int> CheckIsUsed(IRepository repository, CategoryTree categoryTree)
        {
            var query = repository.AsQueryable<WidgetCategory>().Where(ec => ec.Category.CategoryTree == categoryTree
            && !ec.Widget.IsDeleted
            && (ec.Widget.Status == ContentStatus.Draft || ec.Widget.Status == ContentStatus.Published)).ToRowCountFutureValue();

            return query;
        }
开发者ID:wezmag,项目名称:BetterCMS,代码行数:8,代码来源:WidgetCategoryAccessor.cs

示例2: GetWidgetOptionsQuery

 private static IQueryable<OptionModel> GetWidgetOptionsQuery(IRepository repository, Guid widgetId)
 {
     return repository
         .AsQueryable<ContentOption>(o => o.Content.Id == widgetId)
         .Select(o => new OptionModel
             {
                 Key = o.Key,
                 DefaultValue = o.DefaultValue,
                 Type = (OptionType)(int)o.Type,
                 CustomTypeIdentifier = o.CustomOption != null ? o.CustomOption.Identifier : null
             });
 }
开发者ID:Steinerd,项目名称:BetterCMS,代码行数:12,代码来源:WidgetOptionsHelper.cs

示例3: ExecuteWithData

 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var preName = cmd.Split(new[] {' '}, 2);
     var name = preName[1].Split('=')[0].Trim();
     var destinationName = cmd.Split('=')[1].Trim();
     var destination = repo.AsQueryable<GameObject>()
         .OfType<Room>().FirstOrDefault(m => m.Name == destinationName);
     var exit = new Exit() { Name = name.Trim(), Destination = destination, Location = player.Location };
     repo.Add(exit);
     console.WriteLine("Exit created");
     return true;
 }
开发者ID:mrayburn,项目名称:Zorklike,代码行数:12,代码来源:CreateExitCommand.cs

示例4: GetMapRoom

 public Room GetMapRoom(IRepository repo)
 {
     var mapRoom = repo.AsQueryable<GameObject>().OfType<Room>().FirstOrDefault(m => m.Name == "MapRoom");
     if (mapRoom == null)
     {
         mapRoom = new Room();
         mapRoom.Name = "The Map Room";
         repo.Add(mapRoom);
         repo.UnitOfWork.SaveChanges();
     }
     return mapRoom;
 }
开发者ID:mrayburn,项目名称:Zorklike,代码行数:12,代码来源:GameObjectQueries.cs

示例5: GetPlayer

 public Player GetPlayer(IRepository repo)
 {
     var player = repo.AsQueryable<GameObject>().OfType<Player>().FirstOrDefault();
     if (player == null)
     {
         player = new Player();
         player.Location = GetMapRoom(repo);
         player.Aliases.Add(new Tag { Value = "Me" });
         player.Aliases.Add(new Tag { Value = "Player" });
         repo.Add(player);
         repo.UnitOfWork.SaveChanges();
     }
     return player;
 }
开发者ID:mrayburn,项目名称:Zorklike,代码行数:14,代码来源:GameObjectQueries.cs

示例6: GetPagesToFuture

 public static IEnumerable<PageData> GetPagesToFuture(bool enableMultilanguage, IRepository repository)
 {
     return enableMultilanguage ? repository
         .AsQueryable<Root.Models.Page>()
         .Select(p => new PageData
         {
             Id = p.Id,
             Title = p.Title,
             Url = p.PageUrl,
             LanguageId = p.Language != null ? p.Language.Id : Guid.Empty,
             LanguageGroupIdentifier = p.LanguageGroupIdentifier,
             IsPublished = p.Status == PageStatus.Published
         })
         .ToFuture() : null;
 }
开发者ID:JMFURY,项目名称:BetterCMS,代码行数:15,代码来源:SitemapHelper.cs

示例7: ExecuteWithData

        protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
        {
            var parameters = cmd.Split(new[] { ' ' }, 2)[1];
            bool addStatus = parameters.Contains("+=");

            string splitVal;
            if (addStatus) splitVal = "+=";
            else splitVal = "-=";

            var goName = parameters.Split(new[] { splitVal }, StringSplitOptions.None)[0];
            var statusName = parameters.Split(new[] { splitVal }, StringSplitOptions.None)[1];

            var go = queries.FindNearPlayer(repo, player, goName);
            if (go == null)
            {
                formatters.OfType<NotFoundFormatter>().First().Format(go);
                return false;
            }
            else
            {
                var alias = repo.AsQueryable<Tag>().FirstOrDefault(m => m.Value == statusName);

                if (addStatus)
                {
                    if (alias == null)
                    {
                        alias = new Tag { Value = statusName };
                        repo.Add(alias);
                        console.WriteLine("Status created.");
                    }
                    go.Statuses.Add(alias);
                    console.WriteLine("Status added.");
                }
                else
                {
                    if (alias == null)
                    {
                        console.WriteLine("That status does not exist");
                    }
                    else
                    {
                        go.Statuses.Remove(alias);
                        console.WriteLine("Status removed.");
                    }
                }
                return true;
            }
        }
开发者ID:trayburn,项目名称:Adventure,代码行数:48,代码来源:StatusCommand.cs

示例8: IsValid

 public bool IsValid(string input)
 {
     string InputHolder = input;
     if  (((IsFirstWord(InputHolder, "move")) || (IsFirstWord(InputHolder, "go"))))
     {
         InputHolder = GetAllButFirstWord(input);
     }
     using (repository = repoFactory())
     {
         var pObj = repository.AsQueryable().First(qq => qq.GameObjectId == player.Id);
         var exit = pObj.Location.Inventory.Where(qq => qq.Type == "Exit").
             FirstOrDefault(qq => qq.ExitAliases.Any(ww => ww.Alais.Equals(InputHolder, StringComparison.CurrentCultureIgnoreCase))
                 || qq.Name.Equals(InputHolder, StringComparison.CurrentCultureIgnoreCase));
         return exit != null;
     }
 }
开发者ID:csjackson,项目名称:Adventure,代码行数:16,代码来源:MoveCommand.cs

示例9: Execute

        public void Execute(string input)
        {
            string Output = GetAllButFirstWord(input);

              using (repository = repoFactory())
              {
                  var pObj = repository.AsQueryable().First(qq => qq.GameObjectId == player.Id);
                  var WhichExit = pObj.Location.Inventory.FirstOrDefault(qq => (qq.Name.Equals
                      (Output, StringComparison.CurrentCultureIgnoreCase)) && qq.Type=="Exit");
                  if (WhichExit != null)
                  {
                      pObj.Location = WhichExit.DestinationLocation;
                  }
                  format.Output(pObj.Location);
              }
        }
开发者ID:csjackson,项目名称:Adventure,代码行数:16,代码来源:MoveCommand.cs

示例10: GetLayoutRegionsQuery

        private static IQueryable<RegionModel> GetLayoutRegionsQuery(IRepository repository, Guid layoutId)
        {
            return repository
                .AsQueryable<LayoutRegion>(lr => lr.Layout.Id == layoutId && !lr.Layout.IsDeleted && lr.Region != null && !lr.Region.IsDeleted)
                .Select(lr => new RegionModel
                    {
                        Id = lr.Region.Id,
                        Version = lr.Region.Version,
                        CreatedBy = lr.CreatedByUser,
                        CreatedOn = lr.CreatedOn,
                        LastModifiedBy = lr.ModifiedByUser,
                        LastModifiedOn = lr.ModifiedOn,

                        RegionIdentifier = lr.Region.RegionIdentifier,
                        Description = lr.Description
                    });
        }
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:17,代码来源:LayoutServiceHelper.cs

示例11: ExecuteWithData

 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var preName = cmd.Split(new[] { ' ' }, 2);
     var name = preName[1].Split('.')[0];
     var preOpType = preName[1].Split(new[] { '.' }, 2);
     var opType = preOpType[1].Split('=')[0];
     var fieldInput = cmd.Split('=')[1].Trim();
     var go = goQueries.GetGameObjectByNameAndPlayerLocation(repo, name, player);
     if (opType == "+" && go != null)
     {
         var fieldTag = repo.AsQueryable<Tag>().FirstOrDefault(m => m.Value == fieldInput);
         if (fieldTag == null)
         {
             fieldTag = new Tag();
             fieldTag.Value = fieldInput;
         }
         go.Aliases.Add(fieldTag);
         console.WriteLine("Alias set!");
         return true;
     }
     else
     {
         if (go == null)
         {
             console.Write("I don't recognize: ");
             console.WriteLine(name);
             return false;
         }
         else
         {
             if (opType == "-")
             {
                 var fieldTag = go.Aliases.FirstOrDefault(m => m.Value == fieldInput);
                 go.Aliases.Remove(fieldTag);
                 console.WriteLine("Alias removed!");
                 return true;
             }
             else
             {
                 console.Write("I don't recognize: ");
                 console.WriteLine(opType);
                 return false;
             }
         }
     }
 }
开发者ID:mrayburn,项目名称:Zorklike,代码行数:46,代码来源:AliasCommand.cs

示例12: GetWidgetOptionsQuery

 private static IQueryable<OptionModel> GetWidgetOptionsQuery(IRepository repository, Guid widgetId)
 {
     return repository
         .AsQueryable<ContentOption>(o => o.Content.Id == widgetId)
         .Select(o => new OptionModel
             {
                 Key = o.Key,
                 DefaultValue = o.DefaultValue,
                 Type = (OptionType)(int)o.Type,
                 CustomTypeIdentifier = o.CustomOption != null ? o.CustomOption.Identifier : null,
                 Translations = o.Translations.Select(x => new OptionTranslationModel
                 {
                     LanguageId = x.Language.Id.ToString(),
                     Value = x.Value
                 }).ToList()
             });
 }
开发者ID:wezmag,项目名称:BetterCMS,代码行数:17,代码来源:WidgetOptionsHelper.cs

示例13: ExecuteWithData

 protected override bool ExecuteWithData(string cmd, IRepository repo, Player player)
 {
     var locationName = cmd.Split(new[] { ' ' }, 2)[1];
     var location = repo.AsQueryable<GameObject>()
         .OfType<Room>().FirstOrDefault(m => m.Name == locationName);
     if (player.Location == location)
     {
         console.WriteLine("Really!? You are already there!");
         return false;
     }
     else
     {
         player.Location = location;
         console.Write("You have teleported to: ");
         console.WriteLine(player.Location.Name);
         return true;
     }
 }
开发者ID:mrayburn,项目名称:Zorklike,代码行数:18,代码来源:TeleportCommand.cs

示例14: GetPageContentOptionsQuery

        private static IQueryable<OptionValueModel> GetPageContentOptionsQuery(IRepository repository, Guid pageContentId, IOptionService optionService)
        {
            var pageContent = repository
                .AsQueryable<PageContent>()
                .Where(f => f.Id == pageContentId && !f.IsDeleted && !f.Content.IsDeleted)
                .Fetch(f => f.Content).ThenFetchMany(f => f.ContentOptions)
                .FetchMany(f => f.Options)
                .ToList()
                .FirstOne();

            return optionService
                .GetMergedOptionValuesForEdit(pageContent.Content.ContentOptions, pageContent.Options)
                .Select(o => new OptionValueModel
                    {
                        Key = o.OptionKey,
                        Value = o.OptionValue,
                        DefaultValue = o.OptionDefaultValue,
                        Type = ((Root.OptionType)(int)o.Type),
                        UseDefaultValue = o.UseDefaultValue,
                        CustomTypeIdentifier = o.CustomOption != null ? o.CustomOption.Identifier : null
                    }).AsQueryable();
        }
开发者ID:Steinerd,项目名称:BetterCMS,代码行数:22,代码来源:PageContentOptionsHelper.cs

示例15: GetTitlesForValues

        /// <summary>
        /// Gets the titles for values.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="repository">The repository.</param>
        /// <returns>
        /// The dictionary with value - title pairs
        /// </returns>
        public Dictionary<string, string> GetTitlesForValues(string[] values, IRepository repository)
        {
            if (values == null || values.Length == 0)
            {
                return null;
            }

            var guids = new List<Guid>(values.Length);

            foreach (var value in values)
            {
                var guid = ConvertValueToCorrectType(value);
                if (guid != null)
                {
                    guids.Add((Guid)guid);
                }
            }

            Dictionary<string, string> result;
            if (guids.Count > 0)
            {
                result = repository
                    .AsQueryable<MediaFolder>()
                    .Where(a => guids.Contains(a.Id))
                    .Select(a => new { a.Id, a.Title })
                    .ToDictionary(a => a.Id.ToString(), a => a.Title);
            }
            else
            {
                result = new Dictionary<string, string>();
            }

            if (values.Any(string.IsNullOrEmpty))
            {
                result.Add(string.Empty, MediaGlobalization.RootFolder_Title);
            }

            return result;
        }
开发者ID:vivekmalikymca,项目名称:BetterCMS,代码行数:47,代码来源:MediaManagerFolderOptionProvider.cs


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