本文整理汇总了C#中IRepository.Fetch方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Fetch方法的具体用法?C# IRepository.Fetch怎么用?C# IRepository.Fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.Fetch方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HasTagsHandler
public HasTagsHandler(IRepository<Tag> tagsRepository, IRepository<TagsContentItems> tagsContentItemsRepository)
{
OnLoading<HasTags>((context, tags) => {
// provide names of all tags on demand
tags._allTags.Loader(list => tagsRepository.Table.ToList());
// populate list of attached tags on demand
tags._currentTags.Loader(list => {
var tagsContentItems = tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id);
foreach (var tagContentItem in tagsContentItems) {
var tag = tagsRepository.Get(tagContentItem.TagId);
list.Add(tag);
}
return list;
});
});
OnRemoved<HasTags>((context, ht) => {
tagsContentItemsRepository.Flush();
HasTags tags = context.ContentItem.As<HasTags>();
foreach (var tag in tags.CurrentTags) {
if (!tagsContentItemsRepository.Fetch(x => x.ContentItemId == context.ContentItem.Id).Any()) {
tagsRepository.Delete(tag);
}
}
});
}
示例2: WinXinUserInfoPartHandle
public WinXinUserInfoPartHandle(IRepository<WinXinUserInfoPartRecord> winXinUserInfoPartRecordRepository)
{
Filters.Add(new ActivatingFilter<WinXinUserInfoPart>("User"));
OnInitialized<WinXinUserInfoPart>((context, part) => part.Record.Loader(
() => winXinUserInfoPartRecordRepository
.Fetch(x => x.UserId == context.ContentItem.Id).FirstOrDefault()));
}
示例3: Filter
/// <summary>
/// returns EmailQueueItems from the provided context which are belong in the union of all filter cases
/// </summary>
/// <param name="repository">The repository.</param>
/// <returns></returns>
public IEnumerable<EmailQueueItem> Filter(IRepository<EmailQueueItem> repository)
{
if(Filters.Count == 0)
{
this.And(new SentStatusDequeueFilter(false)).And(new RetriesFilter(5));
}
int length = Filters.Count;
var query = repository.Fetch();
while (length > 0)
{
var filter = Filters.Dequeue();
if(filter.Key == FilterOperand.And)
{
query = filter.Value.Filter(query);
}
length--;
//add filter back at the end of the queue so we can use this FilterList over and over.
//Essentially we iterate in place except that it isn't in place.
//Should always be an O(1) operation because I don't think the capacity of the queue ever decreases.
//If O(1), who cares about this then, this function is bounded by O(n)
Filters.Enqueue(filter);
}
return query.ToArray();
}
示例4: UserRolesPartHandler
public UserRolesPartHandler(IRepository<UserRolesPartRecord> userRolesRepository) {
_userRolesRepository = userRolesRepository;
Filters.Add(new ActivatingFilter<UserRolesPart>("User"));
OnInitialized<UserRolesPart>((context, userRoles) => userRoles._roles.Loader(value => _userRolesRepository
.Fetch(x => x.UserId == context.ContentItem.Id)
.Select(x => x.Role.Name).ToList()));
}
示例5: UserRolesHandler
public UserRolesHandler(IRepository<UserRolesRecord> userRolesRepository) {
_userRolesRepository = userRolesRepository;
Filters.Add(new ActivatingFilter<UserRoles>("user"));
OnLoaded<UserRoles>((context, userRoles) => {
userRoles.Roles = _userRolesRepository
.Fetch(x => x.UserId == context.ContentItem.Id)
.Select(x => x.Role.Name).ToList();
});
}
示例6: OrderPartHandler
public OrderPartHandler(
IRepository<OrderPartRecord> repository,
IContentManager contentManager,
IRepository<OrderDetailRecord> orderDetailsRepository,
IOrdersService ordersService,
IRepository<OrderAddressRecord> orderAddressRepository)
{
_orderDetailsRepository = orderDetailsRepository;
Filters.Add(StorageFilter.For(repository));
OnActivated<OrderPart>((context, part) => {
// Details
part._details.Loader(details => _orderDetailsRepository.Fetch(d => d.OrderId == part.Id)
.Select(d => new OrderDetail(d))
.ToList());
// Order total
part._orderTotal.Loader(orderTotal => BuildOrderTotal(part));
// BillingAddress
part._billingAddress.Loader(shippingAddress => orderAddressRepository.Get(part.BillingAddressId));
});
OnLoading<OrderPart>((context, part) => {
// Order total
part._orderTotal.Loader(orderTotal => part.Retrieve(x => x.OrderTotal));
});
OnCreating<OrderPart>((context, part) => {
if (String.IsNullOrWhiteSpace(part.Reference)) {
part.Reference = ordersService.BuildOrderReference();
}
});
OnCreated<OrderPart>((context, part) => {
// Order total
part.OrderTotal = BuildOrderTotal(part);
SaveDetails(part);
part.BillingAddressId = orderAddressRepository.CreateOrUpdate(part.BillingAddress);
});
OnUpdated<OrderPart>((context, part) => {
// Order total
part.OrderTotal = BuildOrderTotal(part);
SaveDetails(part);
part.BillingAddressId = orderAddressRepository.CreateOrUpdate(part.BillingAddress);
});
}
示例7: PostHandler
public PostHandler(ICourseMenuService menuService, IYearService yearService, ICourseService courseService, IRepository<MailSubscriptionRecord> mailRepo, IMembershipService membershipService, IMessageManager messageManager, IRepository<PostRecord> postRepo, IHttpContextAccessor httpContextAccessor)
{
this.courseService = courseService;
this.yearService = yearService;
this.menuService = menuService;
this.httpContextAccessor = httpContextAccessor;
this.postRepo = postRepo;
this.mailRepo = mailRepo;
this.messageManager = messageManager;
this.membershipService = membershipService;
OnPublished<RoutePart>((context, part) =>
{
var item = postRepo.Fetch(x => x.ContentId == part.ContentItem.Id).FirstOrDefault();
if (item != null)
{
var menu = menuService.Get(item.Menu.Id);
sendEmail(menu.Id, part.ContentItem);
}
});
}
示例8: UpdateGit
bool UpdateGit(IRepository repo)
{
var recompileNeeded = true;
using (var _ = new ChangingOutput("Updating source code . . ."))
{
_.FinishLine();
using (var t = new ChangingOutput("Fetching updates from GitHub . . ."))
{
repo.Fetch("origin", new FetchOptions()
{
OnTransferProgress = (x) =>
{
t.PrintProgress((double) x.ReceivedObjects/x.TotalObjects);
return true;
}
});
t.PrintResult(true);
}
var currentCommit = repo.Head.Tip;
MergeResult result;
try
{
using (var t = new ChangingOutput("Merging in updates . . ."))
{
result = repo.Merge(repo.Head.TrackedBranch, new Signature(Environment.UserName, "[email protected]", DateTime.Now),
new MergeOptions
{
CommitOnSuccess = true,
FileConflictStrategy = CheckoutFileConflictStrategy.Ours,
MergeFileFavor = MergeFileFavor.Normal,
OnCheckoutProgress = (n, processed, total) =>
{
t.PrintProgress((double) processed/total);
},
});
t.PrintResult(result.Status != MergeStatus.Conflicts);
}
if (result.Status == MergeStatus.UpToDate)
{
Console.WriteLine("Source was already up to date");
recompileNeeded = RestoreDeleteFiles(repo);
_.PrintResult(true);
}
else if (result.Status == MergeStatus.Conflicts)
{
throw new MergeConflictException();
}
else
{
Console.WriteLine("Updated to {0} : {1}", result.Commit.Sha.Substring(0, 10), result.Commit.MessageShort);
_.PrintResult(true);
}
}
catch (MergeConflictException)
{
Console.WriteLine("Merge resulted in conflicts. This usually indictates a user-edited source");
Console.WriteLine("Your Aura will NOT be updated until you undo your changes to the files.");
Console.WriteLine("This is a bad thing, so fix it ASAP.");
Console.WriteLine("NOTE: If you're trying to make configuration changes, use the \"user\" folders instead.");
Console.WriteLine("Rolling back merge...");
repo.Reset(currentCommit);
recompileNeeded = false;
_.PrintResult(false);
}
return recompileNeeded;
}
}
示例9: ManualsXapp
public ManualsXapp(IAppHandler aHandler)
{
iHandler = aHandler;
iXappMimeTypes = new Dictionary<string, string>();
iXappMimeTypes.Add(".css", "text/css");
iGitMimeTypes = new Dictionary<string, string>();
iGitMimeTypes.Add(".md", "text/md");
iGitMimeTypes.Add(".html", "text/html");
iGitMimeTypes.Add(".css", "text/css");
iGitMimeTypes.Add(".js", "text/javascript");
iGitMimeTypes.Add(".jpg", "image/jpg");
iGitMimeTypes.Add(".png", "image/png");
iResourceFolder = new ResourceFolder("http", iXappMimeTypes, iHandler.AppRoot);
iGitPath = Path.Combine(iHandler.DataRoot, "GitManuals");
iRepository = GitFactory.Open(iGitPath, "git://github.com/cropotkin/Documentation.git");
iRepository.Fetch();
iMarkdown = new Markdown();
iAdvancedModule = new AdvancedModule("openhome.org.advanced", iHandler.AppRoot);
iHandler.RegisterXapp(this, "xapp/main.css", iAdvancedModule);
}