本文整理汇总了C#中IRepository.List方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.List方法的具体用法?C# IRepository.List怎么用?C# IRepository.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.List方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Get
public static BlogSettings Get(IRepository repo)
{
return repo.List<BlogSettings>().Single();
}
示例2: GetPublishedPosts
public static IQueryable<Post> GetPublishedPosts(IRepository repository)
{
//TODO: Limitation in current version of the Norm driver. Need to pull everything
return repository.List<Post>()
.Where(x => x.IsPublished).ToList()
.OrderByDescending(x => x.Created).AsQueryable();
}
示例3: GetTags
public static IQueryable<Tag> GetTags(IRepository repository)
{
//TODO: Nasty. Need to deal with m-m relationships in some way....
var posts = repository.List<Post>().ToList();
var tags = new List<Tag>();
foreach(var post in posts)
{
tags = tags.Union(post.Tags).Distinct().ToList();
}
return tags.AsQueryable();
}
示例4: GenerateRouteDirectionReals
private static void GenerateRouteDirectionReals(Route route, IRepository rep)
{
Dictionary<string, Route> s_routes = null;
if (s_routes == null)
{
var routes = rep.List<Route>();
s_routes = new Dictionary<string, Route>();
foreach (var i in routes)
{
s_routes[i.Name] = i;
}
}
string realRoute = route.DirectionExpression;
if (string.IsNullOrEmpty(route.DirectionExpression))
{
route.DirectionReal = null;
return;
}
string[] subRoute = route.DirectionExpression.Split(new char[] {'|', '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < subRoute.Length; ++i)
{
string s = subRoute[i].Trim();
if (s_routes.ContainsKey(s))
{
if (string.IsNullOrEmpty(s_routes[s].DirectionReal))
{
GenerateRouteDirectionReals(s_routes[s], rep);
}
if (string.IsNullOrEmpty(s_routes[s].DirectionReal))
{
throw new ArgumentException(string.Format("There is no route named of {0}", subRoute[i]));
}
realRoute = realRoute.Replace(subRoute[i], s_routes[subRoute[i]].DirectionReal);
}
}
route.DirectionReal = realRoute;
}