本文整理汇总了C#中Repository.All方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.All方法的具体用法?C# Repository.All怎么用?C# Repository.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoUpdateArsenalMatchResult_Test
public void AutoUpdateArsenalMatchResult_Test()
{
try
{
IRepository repo = new Repository();
var cmList = repo.All<CasinoMatch>();
var mList = repo.All<ArsenalMatch>();
if (mList != null && mList.Count > 0 && cmList != null && cmList.Count > 0)
{
foreach (var m in mList)
{
CasinoMatch cm;
if (m.CasinoMatchGuid.HasValue)
{
//Casino MatchGuid Bound
cm = cmList.Find(x => x.ID.Equals(m.CasinoMatchGuid.Value));
}
else
{
//new Arsenal Match
cm = cmList.Find(x =>
{
if (m.IsHome)
{
return m.TeamGuid.Equals(x.Away) && m.PlayTime.Equals(x.PlayTime);
}
return m.TeamGuid.Equals(x.Home) && m.PlayTime.Equals(x.PlayTime);
});
}
if (cm != null && cm.ResultHome.HasValue && cm.ResultAway.HasValue)
{
if (m.ResultHome.Equals(cm.ResultHome) && m.ResultAway.Equals(cm.ResultAway)
&& m.PlayTime.Equals(cm.PlayTime) && m.CasinoMatchGuid.Equals(cm.ID))
{
continue;
}
m.ResultHome = cm.ResultHome;
m.ResultAway = cm.ResultAway;
m.PlayTime = cm.PlayTime;
m.CasinoMatchGuid = cm.ID;
repo.Update(m);
}
}
}
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}
示例2: AutoUpdateMemberType_Test
public void AutoUpdateMemberType_Test()
{
try
{
IRepository repo = new Repository();
var mlist = repo.All<Member>().FindAll(x => (int)x.MemberType <= 2);
var olist = repo.All<Order>().FindAll(x => x.IsActive);
if (mlist.Count > 0 && olist.Count > 0)
{
// Don't place LINQ to Foreach, first ToList(), then use list.FindAll to improve performance
foreach (var m in mlist)
{
MemberType type;
var list = olist.FindAll(x => x.MemberID == m.ID);
// Refresh the MemberType of instance
if (list.Count > 0)
{
if (list.Exists(x => x.OrderType == OrderBaseType.Ticket || x.OrderType == OrderBaseType.Travel))
{
type = MemberType.Match;
}
else if (list.Exists(x => x.OrderType == OrderBaseType.ReplicaKit ||
x.OrderType == OrderBaseType.Printing || x.OrderType == OrderBaseType.Wish))
{
type = MemberType.Buyer;
}
else
{
type = MemberType.None;
}
}
else
{
type = MemberType.None;
}
if (!m.MemberType.Equals(type))
{
m.MemberType = type;
repo.Update(m);
}
}
}
}
catch (Exception ex)
{
Assert.Fail(ex.Message);
}
}
示例3: Test_All_Pager
public void Test_All_Pager()
{
IRepository repo = new Repository();
// normal condition
IPager pager1 = new Pager(1) { PagingSize = 10 };
Assert.IsFalse(pager1.TotalCount > 0);
var query1 = repo.All<League>(pager1, "LeagueOrder, LeagueOrgName");
var queryVal = repo.All<League>();
Assert.IsNotNull(query1);
Assert.IsInstanceOfType(query1, typeof(List<League>));
Assert.IsTrue(query1.Any());
Assert.IsTrue(pager1.TotalCount > 0);
Assert.AreEqual(pager1.TotalCount.ToString(), queryVal.Count.ToString());
Assert.AreEqual(pager1.PagingSize.ToString(), query1.Count.ToString());
Assert.IsTrue(query1[0].Equals(queryVal[10]));
// large pagingSize
IPager pager2 = new Pager(0) { PagingSize = 1000 };
var query2 = repo.All<League>(pager2, "LeagueOrder, LeagueOrgName");
Assert.IsNotNull(query2);
Assert.IsInstanceOfType(query2, typeof(List<League>));
Assert.IsTrue(query2.Any());
Assert.IsTrue(pager2.TotalCount > 0);
Assert.AreEqual(pager2.TotalCount.ToString(), queryVal.Count.ToString());
Assert.AreEqual(query2.Count.ToString(), queryVal.Count.ToString());
// max currentPage
IPager pager3 = new Pager(1000) { PagingSize = 20 };
var query3 = repo.All<League>(pager3, "LeagueOrder, LeagueOrgName");
Assert.IsNotNull(query3);
Assert.IsInstanceOfType(query3, typeof(List<League>));
Assert.IsTrue(query3.Any());
Assert.IsTrue(pager2.TotalCount > 0);
Assert.AreEqual(pager2.TotalCount.ToString(), queryVal.Count.ToString());
Assert.AreEqual(pager3.CurrentPage.ToString(), pager3.MaxPage.ToString());
Assert.AreEqual(query3.Count.ToString(), (queryVal.Count % pager3.PagingSize).ToString());
}
示例4: Execute
public void Execute(object state)
{
var logInfo = new LogInfo
{
MethodInstance = MethodBase.GetCurrentMethod(),
ThreadInstance = Thread.CurrentThread
};
try
{
_log.Info("Scheduler Start: (AutoUpdateActiveBankerCash)", logInfo);
IRepository repo = new Repository();
var list = repo.All<Banker>().FindAll(x => x.IsActive);
foreach (var b in list)
{
b.Statistic();
}
_log.Info("Scheduler End: (AutoUpdateActiveBankerCash)", logInfo);
}
catch (Exception ex)
{
_log.Warn(ex, logInfo);
}
}
示例5: Execute
public void Execute(object state)
{
var logInfo = new LogInfo
{
MethodInstance = MethodBase.GetCurrentMethod(),
ThreadInstance = Thread.CurrentThread
};
try
{
log.Info("Scheduler Start: (AutoUpdateActiveCasinoItemEarning)", logInfo);
IRepository repo = new Repository();
var list = repo.All<CasinoItem>().FindAll(x =>
x.ItemType.Equals(CasinoType.SingleChoice) && x.Earning.HasValue);
foreach (var c in list)
{
c.Statistics();
}
log.Info("Scheduler End: (AutoUpdateActiveCasinoItemEarning)", logInfo);
}
catch (Exception ex)
{
log.Warn(ex, logInfo);
}
}
示例6: QueryAll
public void QueryAll()
{
var session = GetConnection().CreateSession(_DatabaseName);
var repository = new Repository<ProductTranslation>(session);
var savedProducts = repository.All();
savedProducts.ToList().ForEach(Console.WriteLine);
}
示例7: EntriesCount
public int EntriesCount()
{
using (var repository = new Repository<Entry>())
{
return repository.All().Count();
}
}
示例8: Execute
public void Execute(object state)
{
var logInfo = new LogInfo
{
MethodInstance = MethodBase.GetCurrentMethod(),
ThreadInstance = Thread.CurrentThread
};
try
{
_log.Info("Scheduler Start: (AutoUpdateOrderType)", logInfo);
IRepository repo = new Repository();
var oList = repo.All<Order>();
var oiList = repo.All<OrderItem>().FindAll(x => Product.Cache.Load(x.ProductGuid) != null);
if (oList.Count > 0 && oiList.Count > 0)
{
// Don't place LINQ to Foreach, first ToList(), then use list.FindAll to improve performance
foreach (var o in oList)
{
var list = oiList.FindAll(x => x.OrderID.Equals(o.ID));
// Refresh the OrderType of instance
if (list.Count > 0)
{
var type = Order.GetOrderTypeByOrderItems(list);
if (!o.OrderType.Equals(type))
{
o.OrderType = type;
repo.Update(o);
}
}
}
}
_log.Info("Scheduler End: (AutoUpdateOrderType)", logInfo);
}
catch (Exception ex)
{
_log.Warn(ex, logInfo);
}
}
示例9: Test_All
public void Test_All()
{
IRepository repo = new Repository();
var query = repo.All<League>();
Assert.IsNotNull(query);
Assert.IsInstanceOfType(query, typeof(List<League>));
Assert.IsTrue(query.Any());
}
示例10: List
public List<Entry> List()
{
using (var repository = new Repository<Entry>())
{
return
repository
.All()
.OrderByDescending(e => e.PublishedAt).ToList();
}
}
示例11: PopulateForm
private void PopulateForm()
{
DataLayer.SessionHelper _sessionHelper = new SessionHelper();
Repository<Guid, NewsItem> _newsItemRepo = new Repository<Guid, NewsItem>(_sessionHelper.GetSession("APL"));
UnitOfWork _unitOfWork = new UnitOfWork(_sessionHelper.GetSessionFactory("APL"));
var newsItems = _newsItemRepo.All().ToList();
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.CellContentDoubleClick += DataGridView1_CellContentDoubleClick;
dataGridView1.ReadOnly = true;
dataGridView1.DataSource = newsItems;
}
示例12: Create
public static BoxerNameConstraint Create()
{
var session = Configure.GetSessionFactory().OpenSession();
var repository = new Repository<Boxer>(session);
var allNames = repository.All().Select(x => (x.FirstName.Replace(" ", "_") + "-" + x.LastName.Replace(" ", "_")).ToLowerInvariant()).ToArray();
session.Flush();
session.Dispose();
return new BoxerNameConstraint(allNames);
}
示例13: DecklistByDate
public void DecklistByDate()
{
var targetDate = new DateTime(2014, 01, 01);
var decklistByDates = new Repository().GetDecklistForDay(targetDate);
Assert.IsNotNull(decklistByDates);
Assert.IsTrue(decklistByDates.All(a =>
{
var parseDate = DateTime.Parse(a.Creation);
return (parseDate >= targetDate && parseDate <= parseDate.AddDays(1).AddMinutes(-1));
}));
}
示例14: GetAllStaff
public void GetAllStaff()
{
var repo = new Repository<FieldStaff>(DataService.GetSession());
var staff = repo.All();
Assert.NotNull(staff);
foreach (var staffMember in staff)
{
Assert.NotNull(staffMember);
Assert.NotNull(staffMember.StaffCode);
}
}
示例15: PaginatedList
public PagedList<Entry> PaginatedList(int pageNumber, int pageSize)
{
using (var repository = new Repository<Entry>())
{
var entries =
repository
.All()
.OrderByDescending(e => e.PublishedAt);
return entries.ToPagedList(pageNumber, pageSize);
}
}