本文整理汇总了C#中Repository.List方法的典型用法代码示例。如果您正苦于以下问题:C# Repository.List方法的具体用法?C# Repository.List怎么用?C# Repository.List使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Repository
的用法示例。
在下文中一共展示了Repository.List方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ListShouldReturnAllPersistedDocumentsOfTheSpecifiedType
public void ListShouldReturnAllPersistedDocumentsOfTheSpecifiedType()
{
var books = CreateTenBooks();
using (var session = _documentStore.OpenSession())
{
var repo = new Repository(session);
var retrievedBooks = repo.List<Book>();
Assert.AreEqual(books.Count, retrievedBooks.Count);
}
}
示例2: OnActionExecuting
protected override void OnActionExecuting(ActionExecutingContext filterContext)
{
Repository = GetRepository();
var staticPages = Repository.List<StaticPage>();
staticPages.Sort((x, y) => x.CreatedAt.CompareTo(y.CreatedAt));
ViewBag.StaticPages = staticPages;
foreach (StaticPage page in ViewBag.StaticPages)
{
Repository.Detach(page);
}
base.OnActionExecuting(filterContext);
}
示例3: Run
public void Run()
{
using (var sut = new Repository(SERVER, TokenRepository.LoadFrom("ftp.credentials.txt"), "AppZwitschern_TweetStore"))
{
Console.WriteLine("storing...");
var versandaufträge = new[]
{
new Versandauftrag()
{Id = "1", Termin = new DateTime(2012, 3, 26, 12, 21, 0), Text = "a"},
new Versandauftrag()
{Id = "2", Termin = new DateTime(2011, 10, 27, 14, 17, 0), Text = "b"}
,
null
};
var versandt = false;
versandaufträge.ToList().ForEach(_ => sut.Store(_, () => versandt = true));
Console.WriteLine(" stored!");
Assert.IsTrue(versandt);
Console.WriteLine("listing...");
var filenames = new List<string>();
sut.List(filenames.Add);
filenames.ForEach(fn => Console.WriteLine("list {0}", fn));
Assert.AreEqual(3, filenames.Count);
Console.WriteLine("loading...");
var results = new List<Versandauftrag>();
filenames.ForEach(fn => sut.Load(fn, results.Add));
Console.WriteLine(" loaded!");
Assert.That(results.Select(_ => _ == null ? null : _.Id).ToArray(),
Is.EquivalentTo(new[] {"1", "2", null}));
Console.WriteLine("deleting...");
var deleted = false;
results.ForEach(va => sut.Delete(va, () => deleted = true));
Console.WriteLine(" deleted!");
Assert.IsTrue(deleted);
}
}
示例4: Run
public void Run()
{
const string TEST_REPO_PATH = @"c:\appzwitschern";
if (Directory.Exists(TEST_REPO_PATH)) Directory.Delete(TEST_REPO_PATH, true);
var repo = new Repository(TEST_REPO_PATH);
var va1 = new Versandauftrag() { Text = "a", Termin = new DateTime(2012, 6, 21), Id = Guid.NewGuid().ToString() };
repo.Store(va1, null);
var endOfStream = false;
var va2 = new Versandauftrag() { Text = "b", Termin = new DateTime(2012, 6, 20), Id = Guid.NewGuid().ToString() };
repo.Store(va2, null);
repo.Store(null, () => endOfStream = true);
Assert.IsTrue(endOfStream);
endOfStream = false;
var results = new List<string>();
repo.List(results.Add);
Assert.That(results.Select(fn => fn==null ? null : Path.GetFileName(fn)).ToArray(),
Is.EquivalentTo(new[] { va1.Id + ".tweet", va2.Id + ".tweet", null }));
var resultVAs = new List<Versandauftrag>();
foreach(var fn in results)
repo.Load(fn, resultVAs.Add);
Assert.That(resultVAs.Select(_ => _==null ? null : _.Text).ToArray(),
Is.EquivalentTo(new[]{"a", "b", null}));
resultVAs.ForEach(va => repo.Delete(va, () => endOfStream = true));
Assert.AreEqual(0, Directory.GetFiles(TEST_REPO_PATH).Length);
Assert.IsTrue(endOfStream);
Directory.Delete(TEST_REPO_PATH);
}
示例5: Default
public ActionResult Default(string addr, string criteria, string[] sel0, string searchCriteriaTxt, string btnNext, string btnPrevious, string postLat, string postLng, string postZip)
{
GetTopPlanters();
ViewData["LocLat"] = postLat;
ViewData["LocLng"] = postLng;
#region fb Coding
string appid = ConfigurationManager.AppSettings["AppID"];
ViewData["AppID"] = ConfigurationManager.AppSettings["AppID"];
Repository repoObj = new Repository();
Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
if (memberData != null)
{
}
else
{
FacebookConnect fbConnect = new FacebookConnect();
if (fbConnect.IsConnected)
{
// message = "You are connected to Facebook";
//Use the wrapper class to get the access token
string token = fbConnect.AccessToken;
//Alternatively you can just pull the accesstoken out directly with the following line
//string token = HttpContext.Request.Cookies["fbs_" + ConfigurationManager.AppSettings["AppID"]]["\"access_token"];
//Note - you need to decode the token or it will be encoded twice.
token = HttpUtility.UrlDecode(token);
FacebookAPI api = new FacebookAPI(token);
JSONObject me = api.Get("/" + fbConnect.UserID);
SessionStore.SetSessionValue(SessionStore.FacebookConnect, "FacebookUserLoggedIn");
return RedirectToAction("DiscoverSeed", "Seed");
}
else
{
}
}
#endregion
#region Search Code
//Category Selected Seeds
Session["SelectedCategory"] = null;
str = sel0;
string myChoise = null;
if (sel0 != null)
{
for (int i = 0; i < sel0.Length; i++)
{
if (i == 0)
{
myChoise = sel0[0];
}
else
{
myChoise = myChoise + "," + sel0[i];
}
}
}
Session["SelectedCategory"] = myChoise;
ViewData["SelectedCategory"] = Session["SelectedCategory"];
if (sel0 != null)
{
if (sel0.Count() == 1 && sel0[0].ToString().Equals("all"))
Session["SelectedCategory"] = null;
}
#endregion
#region Home Page Paging
if (btnNext == ".." || btnPrevious == ".")
{
int PageCount = Convert.ToInt32(Session["PageCount"]);
int rowCount = Convert.ToInt32(Session["RowCount"]);
int NoOfPage = rowCount / 10;
if (rowCount % 10 != 0)
{
NoOfPage += 1;
}
IList<Seed> lstseed = (IList<Seed>)SessionStore.GetSessionValue(SessionStore.DiscoverSeed);
if (btnNext != null && btnNext == "..")
{
int skipRecord = PageCount * 10;
IList<Seed> lst = lstseed.Skip(skipRecord).ToList();
ViewData["SeedList"] = lst.Take(10).ToList();
PageCount += 1;
Session["PageCount"] = PageCount;
if (PageCount == NoOfPage)
{
ViewData["NxtVisibility"] = "visibility:hidden;";
ViewData["PrevVisibility"] = "visibility:visible;";
}
}
else if (btnPrevious != null && btnPrevious == ".")
//.........这里部分代码省略.........
示例6: GetTopPlanters
public void GetTopPlanters()
{
#region
Member memberData = (Member)SessionStore.GetSessionValue(SessionStore.Memberobject);
Repository repoObj = new Repository();
IList<TopSeedPlanter> listTopPlanters = repoObj.ListP<TopSeedPlanter>("Usp_GetTopSeedPlanter").ToList();
IList<Member> mostFollowedList = repoObj.List<Member>(x => x.id.Equals(x.FollowPeoples1.FirstOrDefault().Member1.id)).OrderByDescending(x => x.FollowPeoples1.Count()).Take(10).ToList();
if (memberData != null)
{
listTopPlanters = listTopPlanters.Where(x => x.id != memberData.id).ToList();
mostFollowedList = mostFollowedList.Where(x => x.id != memberData.id).ToList();
}
ViewData["TopPlanters"] = listTopPlanters;
ViewData["MostFollowed"] = mostFollowedList;
#endregion
}
示例7: ShouldListSecondPage
public void ShouldListSecondPage()
{
using (var session = _documentStore.OpenSession())
{
session.Store(new StaticPage { Title = "test2", UpdatedAt = DateTime.Now.AddMinutes(1) });
session.Store(new StaticPage { Title = "test", UpdatedAt = DateTime.Now });
session.SaveChanges();
var repository = new Repository(session);
Assert.AreEqual("test", repository.List<StaticPage>(2, 1).First().Title);
}
}
示例8: ShouldKnowHowToTakeNDocuments
public void ShouldKnowHowToTakeNDocuments()
{
using (var session = _documentStore.OpenSession())
{
session.Store(new StaticPage { Title = "test" });
session.Store(new StaticPage { Title = "test2" });
session.SaveChanges();
var repository = new Repository(session);
Assert.AreEqual(1, repository.List<StaticPage>(1, 1).Count());
}
}