本文整理汇总了C#中QueryFilter.Add方法的典型用法代码示例。如果您正苦于以下问题:C# QueryFilter.Add方法的具体用法?C# QueryFilter.Add怎么用?C# QueryFilter.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryFilter
的用法示例。
在下文中一共展示了QueryFilter.Add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestListElementsInProjects
public void TestListElementsInProjects()
{
var projects = CreateProjects ();
QueryFilter filter = new QueryFilter ();
filter.Add ("Parent", projects);
Assert.AreEqual (9, storage.Retrieve<EventType> (filter).Count ());
Assert.AreEqual (2, storage.Retrieve<SportsTeam> (filter).Count ());
Assert.AreEqual (8, storage.Retrieve<PlayerLongoMatch> (filter).Count ());
}
示例2: TestQueryProjects
public void TestQueryProjects()
{
QueryFilter filter;
foreach (string comp in new []{"Liga", "Champions", "Copa"}) {
foreach (string season in new []{"2013", "2014", "2015"}) {
foreach (string team in new []{"Barça", "Complu", "Santomera"}) {
ProjectLongoMatch p = new ProjectLongoMatch ();
p.Description = new ProjectDescription ();
p.Description.Season = season;
p.Description.Competition = comp;
p.Description.LocalName = team;
p.Description.VisitorName = "Fluendo";
storage.Store (p);
}
}
}
filter = new QueryFilter ();
filter.Add ("Competition", "Liga");
Assert.AreEqual (9, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
filter.Add ("Competition", "Liga", "Champions");
Assert.AreEqual (18, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
filter.Add ("Season", "2013");
Assert.AreEqual (6, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
filter.Add ("Season", "2013", "2015");
Assert.AreEqual (12, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
filter = new QueryFilter ();
filter.Add ("Season", "2013");
filter.Add ("Competition", "Liga");
filter.Add ("LocalName", "Complu");
Assert.AreEqual (1, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
filter.Add ("VisitorName", "Fluendo");
Assert.AreEqual (1, storage.Retrieve<ProjectLongoMatch> (filter).Count ());
}
示例3: TestQueryTeams
public void TestQueryTeams()
{
IEnumerable<SportsTeam> teams;
for (int i = 0; i < 5; i++) {
var da = SportsTeam.DefaultTemplate (5);
da.Name = "Team" + (i + 1);
storage.Store (da);
}
QueryFilter filter = new QueryFilter ();
filter.Add ("Name", "Team1");
teams = storage.Retrieve<SportsTeam> (filter);
Assert.AreEqual (1, teams.Count ());
Assert.AreEqual ("Team1", teams.First ().Name);
filter.Add ("Name", "Team1", "Team3");
teams = storage.Retrieve<SportsTeam> (filter);
Assert.AreEqual (2, teams.Count ());
Assert.IsTrue (teams.Any (d => d.Name == "Team1"));
Assert.IsTrue (teams.Any (d => d.Name == "Team3"));
filter = new QueryFilter ();
filter.Add ("Name", "Pepe");
teams = storage.Retrieve<SportsTeam> (filter);
Assert.AreEqual (0, teams.Count ());
filter = new QueryFilter ();
filter.Add ("Unkown", "Pepe");
Assert.Throws<InvalidQueryException> (
delegate {
teams = storage.Retrieve<SportsTeam> (filter).ToList ();
});
Assert.AreEqual (0, teams.Count ());
}
示例4: TestQueryEventsByPlayerEventTypeAndProject
public void TestQueryEventsByPlayerEventTypeAndProject()
{
Dashboard dashbaord;
SportsTeam devTeam, qaTeam;
List<ProjectLongoMatch> projects;
projects = CreateProjects ();
dashbaord = projects [0].Dashboard;
devTeam = projects [0].LocalTeamTemplate;
qaTeam = projects [0].VisitorTeamTemplate;
QueryFilter filter = new QueryFilter ();
filter.Add ("Parent", projects [0], projects [1]);
Assert.AreEqual (80, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Player", devTeam.List [0], qaTeam.List [1]);
Assert.AreEqual (20, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", (dashbaord.List [0] as AnalysisEventButton).EventType);
Assert.AreEqual (4, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Team", devTeam);
var res = storage.Retrieve<TimelineEventLongoMatch> (filter);
Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}
示例5: TestQueryEventsByTeam
public void TestQueryEventsByTeam()
{
SportsTeam devTeam, qaTeam;
List<ProjectLongoMatch> projects;
projects = CreateProjects ();
devTeam = projects [0].LocalTeamTemplate;
qaTeam = projects [0].VisitorTeamTemplate;
QueryFilter filter = new QueryFilter ();
filter.Add ("Team", devTeam);
Assert.AreEqual (125, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter = new QueryFilter ();
filter.Add ("Team", qaTeam);
Assert.AreEqual (75, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}
示例6: TestQueryEventsByPlayer
public void TestQueryEventsByPlayer()
{
PlayerLongoMatch andoni = new PlayerLongoMatch { Name = "Andoni" };
PlayerLongoMatch jorge = new PlayerLongoMatch { Name = "Jorge" };
PlayerLongoMatch victor = new PlayerLongoMatch { Name = "Victor" };
PlayerLongoMatch josep = new PlayerLongoMatch { Name = "Josep" };
PlayerLongoMatch davide = new PlayerLongoMatch { Name = "Davide" };
PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" };
PlayerLongoMatch ukelele = new PlayerLongoMatch { Name = "ukelele" };
var players = new List<PlayerLongoMatch> { andoni, jorge, victor, josep, davide };
foreach (PlayerLongoMatch player in players) {
TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
evt.Players.Add (player);
evt.Players.Add (messi);
storage.Store (evt);
}
QueryFilter filter = new QueryFilter ();
filter.Add ("Player", messi);
Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Player", andoni);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Player", andoni, jorge, josep);
Assert.AreEqual (3, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Player", victor, ukelele);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("Player", players);
Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}
示例7: TestQueryEventsByNoPlayerOrTeam
public void TestQueryEventsByNoPlayerOrTeam()
{
PlayerLongoMatch messi = new PlayerLongoMatch { Name = "Messi" };
TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
evt.Players.Add (messi);
storage.Store (evt);
evt = new TimelineEventLongoMatch ();
storage.Store (evt);
QueryFilter filter = new QueryFilter ();
PlayerLongoMatch nullPlayer = null;
SportsTeam nullTeam = null;
filter.Add ("Player", nullPlayer);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter = new QueryFilter ();
filter.Add ("Team", nullTeam);
Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter = new QueryFilter ();
QueryFilter teamsAndPlayersFilter = new QueryFilter { Operator = QueryOperator.Or };
filter.Children.Add (teamsAndPlayersFilter);
teamsAndPlayersFilter.Add ("Team", nullTeam);
teamsAndPlayersFilter.Add ("Player", nullPlayer);
filter.Operator = QueryOperator.Or;
Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}
示例8: TestQueryEventsByEventType
public void TestQueryEventsByEventType()
{
AnalysisEventType evtType1 = new AnalysisEventType { Name = "Ball lost" };
AnalysisEventType evtType2 = new AnalysisEventType { Name = "PC" };
AnalysisEventType evtType3 = new AnalysisEventType { Name = "Recovery" };
AnalysisEventType evtType4 = new AnalysisEventType { Name = "Throw-in" };
AnalysisEventType evtType5 = new AnalysisEventType { Name = "Unused" };
ScoreEventType score = new ScoreEventType { Name = "Goal" };
var eventTypes = new List<EventType> { evtType1, evtType2, evtType3, evtType4, score };
foreach (EventType evtType in eventTypes) {
TimelineEventLongoMatch evt = new TimelineEventLongoMatch ();
evt.EventType = evtType;
storage.Store (evt);
}
QueryFilter filter = new QueryFilter ();
filter.Add ("EventType", evtType1);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", evtType4);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", evtType2, evtType3);
Assert.AreEqual (2, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", eventTypes);
Assert.AreEqual (5, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", evtType5);
Assert.AreEqual (0, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
filter.Add ("EventType", score);
Assert.AreEqual (1, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}
示例9: TestQueryDashboards
public void TestQueryDashboards()
{
IEnumerable<DashboardLongoMatch> dashboards;
for (int i = 0; i < 5; i++) {
var da = DashboardLongoMatch.DefaultTemplate (5);
da.Name = "Dashboard" + (i + 1);
storage.Store (da);
}
QueryFilter filter = new QueryFilter ();
filter.Add ("Name", "Dashboard1");
dashboards = storage.Retrieve<DashboardLongoMatch> (filter);
Assert.AreEqual (1, dashboards.Count ());
Assert.AreEqual ("Dashboard1", dashboards.First ().Name);
filter.Add ("Name", "Dashboard1", "Dashboard3");
dashboards = storage.Retrieve<DashboardLongoMatch> (filter);
Assert.AreEqual (2, dashboards.Count ());
Assert.IsTrue (dashboards.Any (d => d.Name == "Dashboard1"));
Assert.IsTrue (dashboards.Any (d => d.Name == "Dashboard3"));
filter = new QueryFilter ();
filter.Add ("Name", "Pepe");
dashboards = storage.Retrieve<DashboardLongoMatch> (filter);
Assert.AreEqual (0, dashboards.Count ());
filter = new QueryFilter ();
filter.Add ("Unkown", "Pepe");
Assert.Throws<InvalidQueryException> (
delegate {
dashboards = storage.Retrieve<DashboardLongoMatch> (filter).ToList ();
});
Assert.AreEqual (0, dashboards.Count ());
}
示例10: TestNestedQueries
public void TestNestedQueries()
{
SportsTeam devTeam, qaTeam;
List<ProjectLongoMatch> projects;
projects = CreateProjects ();
devTeam = projects [0].LocalTeamTemplate;
qaTeam = projects [0].VisitorTeamTemplate;
QueryFilter filter = new QueryFilter ();
filter.Add ("Parent", projects);
Assert.AreEqual (200, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
QueryFilter teamsPlayersFilter = new QueryFilter { Operator = QueryOperator.Or };
teamsPlayersFilter.Add ("Team", qaTeam);
filter.Children.Add (teamsPlayersFilter);
Assert.AreEqual (75, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
teamsPlayersFilter.Add ("Player", devTeam.List [0]);
Assert.AreEqual (100, storage.Retrieve<TimelineEventLongoMatch> (filter).Count ());
}