本文整理汇总了C#中IRepository.Get方法的典型用法代码示例。如果您正苦于以下问题:C# IRepository.Get方法的具体用法?C# IRepository.Get怎么用?C# IRepository.Get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRepository
的用法示例。
在下文中一共展示了IRepository.Get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Delete_Should_Remove_Item_By_Key
public void Delete_Should_Remove_Item_By_Key(IRepository<Contact, string> repository)
{
var contact = new Contact { Name = "Test User" };
repository.Add(contact);
var result = repository.Get(contact.ContactId);
result.ShouldNotBeNull();
repository.Delete(contact.ContactId);
result = repository.Get(contact.ContactId);
result.ShouldBeNull();
}
示例2: OrderShippingPartHandler
public OrderShippingPartHandler(
IRepository<OrderShippingPartRecord> repository,
IRepository<OrderAddressRecord> orderAddressRepository)
{
Filters.Add(StorageFilter.For(repository));
OnActivated<OrderShippingPart>((context, part) => {
part._shippingDetails.Loader(shippingDetails => {
var orderPart = context.ContentItem.As<OrderPart>();
if (orderPart != null) {
return orderPart.Details.Where(d => d.DetailType == "Shipping");
}
else {
return new List<OrderDetail>();
}
});
part._shippingAddress.Loader(shippingAddress => orderAddressRepository.Get(part.ShippingAddressId));
});
OnCreated<OrderShippingPart>((context, part) => {
part.ShippingAddressId = orderAddressRepository.CreateOrUpdate(part.ShippingAddress);
});
OnUpdated<OrderShippingPart>((context, part) => {
part.ShippingAddressId = orderAddressRepository.CreateOrUpdate(part.ShippingAddress);
});
}
示例3: GiveCampSettings
public GiveCampSettings()
{
repository = new EntityFrameworkRepository();
var settings = repository.Get<EventSetting>(x => x.Id == DefaultId);
HttpRuntime.Cache.Insert("Settings", settings, null, DateTime.Now.AddMinutes(10d), System.Web.Caching.Cache.NoSlidingExpiration);
}
示例4: 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);
}
}
});
}
示例5: MainAsync
static async Task MainAsync(IRepository<SampleEntity> repo)
{
foreach (var s in await repo.GetAllAsync())
{
Console.WriteLine("{0} | {1}", s.ID, s.Name);
}
// Paged Set //
Console.WriteLine("\nPage = 2 - Page Size = 2 :");
var some = await repo.GetAsync(2, 2, s => s.ID);
foreach (var s in some)
{
Console.WriteLine("{0} | {1}", s.ID, s.Name);
}
// Updating //
var fox = await repo.FindAsync(e => e.Name == "Fox");
fox.Name = "Dog";
repo.Update(fox, fox.ID);
// Deleting //
Console.WriteLine("\n " + await repo.DeleteAsync(repo.Get(5)) + "\n");
foreach (var e in repo.GetAll())
Console.WriteLine(e.ID + " | " + e.Name);
}
示例6: CombineDecisions
public void CombineDecisions(IAccessDecisionCombinator combinator, IRepository<Role> roleRepository)
{
if (_disabled) return;
foreach (var roleId in _roles) {
roleRepository.Get(roleId).CombineDecisions(combinator);
}
}
示例7: Update_Should_Save_Modified_Business_Name
public void Update_Should_Save_Modified_Business_Name(IRepository<Contact, string> repository)
{
var contact = new Contact { Name = "Test User" };
repository.Add(contact);
var contact2 = new Contact { Name = "Test User 2" };
repository.Add(contact2);
contact.Name = "Test User - Updated";
repository.Update(contact);
var updated = repository.Get(contact.ContactId);
var notUpdated = repository.Get(contact2.ContactId);
updated.Name.ShouldEqual("Test User - Updated");
notUpdated.Name.ShouldEqual("Test User 2");
}
示例8: LowHealthUnitsWalkTogetherRule
public LowHealthUnitsWalkTogetherRule(ComponentService componentService, AIDto ai, IRepository<GameEnvironment> gameEnvironmentRepository, IVector2Service vector2Service, IEventStoreService eventStoreService)
{
_componentService = componentService;
_ai = ai;
_vector2Service = vector2Service;
_eventStoreService = eventStoreService;
_gameEnvironment = gameEnvironmentRepository.Get();
}
示例9: Get_With_String_Selector_Should_Return_Item_If_Item_Exists
public void Get_With_String_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
{
var contact = new Contact { Name = "Test User" };
repository.Add(contact);
var result = repository.Get(contact.ContactId, c => c.Name);
result.ShouldEqual("Test User");
}
示例10: GetPushEventExample
private static void GetPushEventExample(IRepository<EventPushCampaign> eventPushRepo)
{
var e = eventPushRepo.Get(4251);
Console.WriteLine("Fetched event: {0}", e.Id);
Console.WriteLine("Channels: {0}", String.Join(", ", e.ChannelIds));
Console.WriteLine("Targets: {0}", String.Join(", ", e.Targets));
}
示例11: PeopleViewModel
public PeopleViewModel(IRepository<Person> repository, IEventAggregator eventAggregator)
{
People = new ListCollectionView(repository.Get());
People.CurrentChanged += new EventHandler(OnSelectedItemChanged);
this.eventAggregator = eventAggregator;
}
示例12: Get_Should_Return_Item_If_Item_Exists
public void Get_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
{
var contact = new Contact { Name = "Test User", ContactTypeId = 1 };
repository.Add(contact);
var result = repository.Get(contact.ContactId);
result.Name.ShouldEqual(contact.Name);
result.ContactTypeId.ShouldEqual(contact.ContactTypeId);
}
示例13: Get_With_Anonymous_Class_Selector_Should_Return_Item_If_Item_Exists
public void Get_With_Anonymous_Class_Selector_Should_Return_Item_If_Item_Exists(IRepository<Contact, string> repository)
{
var contact = new Contact { Name = "Test User", ContactTypeId = 2 };
repository.Add(contact);
var result = repository.Get(contact.ContactId, c => new { c.ContactTypeId, c.Name });
result.ContactTypeId.ShouldEqual(2);
result.Name.ShouldEqual("Test User");
}
示例14: BuildBarrackRule
public BuildBarrackRule(ComponentService componentService, AIDto ai, IOrientationService orientationService, IVector2Service vector2Service, IRepository<GameEnvironment> gameEnvironmentRepository, IEventStoreService eventStoreService)
{
_componentService = componentService;
_ai = ai;
_orientationService = orientationService;
_vector2Service = vector2Service;
_eventStoreService = eventStoreService;
_gameEnvironment = gameEnvironmentRepository.Get();
}
示例15: Using_TransactionScope_Without_Complete_Should_Not_Add
public void Using_TransactionScope_Without_Complete_Should_Not_Add(IRepository<Contact, string> repository)
{
repository.Get("test"); // used to create the SqlCe database before being inside the transaction scope since that throws an error
using (var trans = new TransactionScope())
{
repository.Add(new Contact {Name = "Contact 1"});
}
repository.GetAll().Count().ShouldEqual(0);
}