本文整理汇总了C#中IEnumerable.AsQueryable方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.AsQueryable方法的具体用法?C# IEnumerable.AsQueryable怎么用?C# IEnumerable.AsQueryable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.AsQueryable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PredictionViewModel
public PredictionViewModel(Season currentSeason, Player currentLoggedInPlayer, IEnumerable<Comment> Comments)
{
LoggedInPlayer = currentLoggedInPlayer;
Week week = currentSeason.GetCurrentWeekSeason();
CurrentWeekText = string.Format("This Week runs from {0} too {1}, This weeks cutoff for predictions is at {2} on the {3}",
week.WeekStarts.ordinalDateShortDay(),
week.WeekEnds.ordinalDateShortDay(),
week.WeekCutOff.ToString("hh:mm tt"),
week.WeekCutOff.ordinalDateShortDay());
ThisWeeksMatches = week.AllMatches().OrderBy(m =>m.MatchDate.Value);
MatchOfTheWeek = week.MatchOfTheWeek;
var PPs = new Dictionary<Player, IEnumerable<PlayerPrediction>>();
var PlayersWithCompletedPredictions = currentSeason.League.Players.Where(p => p.HasCompletedPredictions(week));
foreach (var p in PlayersWithCompletedPredictions.OrderByDescending(x=>x.CurrentTotalPoints(currentSeason)))
{
PPs.Add(p, p.GetPredictionsForThisWeek().OrderBy(m => m.Match.MatchDate.Value));
}
PlayerPredictions = PPs;
//comments
CommentModel = new CommentingViewModel(7, week.Id, Comments.AsQueryable(), LoggedInPlayer);
}
示例2: FindBiggestCommonType
/// <summary>
/// Finds the biggest common type of items in the list.
/// </summary>
/// <param name="items">The list.</param>
/// <returns>
/// The biggest common type.
/// </returns>
public static Type FindBiggestCommonType(IEnumerable items)
{
if (items == null)
{
return null;
}
Type type = null;
foreach (var item in items)
{
if (item == null)
{
continue;
}
Type itemType = item.GetType();
if (type == null)
{
type = itemType;
continue;
}
while (type != null && type.BaseType != null && !type.IsAssignableFrom(itemType))
{
type = type.BaseType;
}
}
if (type == null && items is IList)
{
type = items.AsQueryable().ElementType;
}
return type;
}
示例3: AnnualExpenseSummary
public AnnualExpenseSummary(Client client, IEnumerable<Employee> employees)
{
ClientCompany = client;
Employees = employees.AsQueryable();
CalculatStatistics();
}
示例4: TestJoinOnly
public void TestJoinOnly(IEnumerable<Foo> foos, IEnumerable<Foo> bars)
{
var actual = Factory.MemoryGroupJoin(foos.AsQueryable(), bars.AsQueryable(), f => f.Id, b => b.Id, (f, b) => new { Id = f.Id, BarCount = b.Count() });
var expected = foos.GroupJoin(bars, f => f.Id, i => i.Id, (f, b) => new { Id = f.Id, BarCount = b.Count() });
Assert.That(actual.ToArray(), Is.EquivalentTo(expected));
}
示例5: GetResult
public IEnumerable<ShipData> GetResult( IEnumerable<ShipData> list ) {
if ( predicate == null )
throw new InvalidOperationException( "式がコンパイルされていません。" );
return list.AsQueryable().Where( predicate ).AsEnumerable();
}
示例6: SetUp
public override void SetUp()
{
base.SetUp();
_patients = Fixture.CreateMany<Domain.Patient>();
_patientRepositoryMock.Setup(r => r.GetPatients()).Returns(_patients.AsQueryable());
}
示例7: SetupUnitOfWork
private Mock<IUnitOfWork> SetupUnitOfWork(IEnumerable<Form> data)
{
var unitOfWork = new Mock<IUnitOfWork>();
string[] includeNames = { "Topics", "Topics.Questions", "Topics.Questions.Answers" };
unitOfWork.Setup(u => u.Query<Form>(includeNames)).Returns(data.AsQueryable());
return unitOfWork;
}
示例8: EstablishContext
protected override void EstablishContext()
{
//Prepare supplied data collections
suppliedListMetadata = GetSuppliedListMetadata();
suppliedStudentRow = GetSuppliedStudentRow();
suppliedPriorYearStudentRow = GetSuppliedPriorYearStudentList();
suppliedMetricVariants = GetSuppliedMetricVariants();
//Set up the mocks
listMetadataProvider = mocks.StrictMock<IListMetadataProvider>();
studentListUtilitiesProvider = mocks.StrictMock<IStudentListUtilitiesProvider>();
trendRenderingDispositionProvider = mocks.StrictMock<ITrendRenderingDispositionProvider>();
metricStateProvider = mocks.StrictMock<IMetricStateProvider>();
metricVariantRepository = mocks.StrictMock<IRepository<MetricVariant>>();
windsorContainer = new WindsorContainer();
windsorContainer.Kernel.Resolver.AddSubResolver(new ArrayResolver(windsorContainer.Kernel));
RegisterProviders(windsorContainer);
IoC.Initialize(windsorContainer);
additionalPriorYearMetricProvider = IoC.Resolve<IAdditionalPriorYearMetricProvider>();
Expect.Call(metricVariantRepository.GetAll())
.Return(suppliedMetricVariants.AsQueryable()).Repeat.AtLeastOnce();
}
示例9: SetUp
public void SetUp()
{
_documents = new List<Document> {new Document()};
var repository = MockRepository.GenerateMock<IRepository>();
_homeController = new HomeController(repository);
repository.Stub(x => x.All<Document>()).Return(_documents.AsQueryable());
}
示例10: Create
public static IPackageRepositoryFactory Create(IEnumerable<IPackage> packages)
{
var packageRepositoryFactory = Substitute.For<IPackageRepositoryFactory>();
packageRepositoryFactory
.CreateRepository("repository")
.GetPackages()
.Returns(packages.AsQueryable());
return packageRepositoryFactory;
}
示例11: Delete
public void Delete(IEnumerable<long> itemKeys)
{
_items.Query()
.Join(itemKeys.AsQueryable(),
item => item.ItemPKey, key => key,
(item, key) => item)
.ToList()
.ForEach(itm => _items.Delete(itm));
_save.Save();
}
示例12: TownRepositoryWithOptimizeRegionTestHelper
public TownRepositoryWithOptimizeRegionTestHelper(
IEnumerable<Town> towns, IEnumerable<OptimizeRegion> regions)
{
this.towns = towns;
this.regions = regions;
townRepository.Setup(x => x.GetAll()).Returns(towns.AsQueryable());
townRepository.Setup(x => x.GetAllList()).Returns(townRepository.Object.GetAll().ToList());
townRepository.Setup(x => x.Count()).Returns(townRepository.Object.GetAll().Count());
controller = new RegionController(townRepository.Object, null, null, regionRepository.Object);
}
示例13: CheckMetadataStringOperator
private IEnumerable<Node> CheckMetadataStringOperator(MappingToolDatabaseDataContext dbContext, IEnumerable<Node> nodes, GraphQueryMetadata metadataTest)
{
List<Node> filteredNodes = null;
if (metadataTest.Operator.Equals("Contains", StringComparison.InvariantCultureIgnoreCase))
{
IQueryable<Node> queryableNodes = nodes.AsQueryable();
var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataContains(metadataTest.Name, metadataTest.Value) select dbMetadata;
int counter = filteredMetadata.Count();
filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
}
else if (metadataTest.Operator.Equals("FreeText", StringComparison.InvariantCultureIgnoreCase))
{
IQueryable<Node> queryableNodes = nodes.AsQueryable();
var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataFreeText(metadataTest.Name, metadataTest.Value) select dbMetadata;
int counter = filteredMetadata.Count();
filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
}
else
{
filteredNodes = new List<Node>();
foreach (Node node in nodes)
{
if (metadataTest.Operator.Equals("Equals", StringComparison.InvariantCultureIgnoreCase))
{
if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue.Contains(metadataTest.Value)).Count() > 0)
{
filteredNodes.Add(node);
}
}
else if (metadataTest.Operator.Equals("NotEquals", StringComparison.InvariantCultureIgnoreCase))
{
if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue != metadataTest.Value).Count() > 0)
{
filteredNodes.Add(node);
}
}
}
}
return filteredNodes;
}
示例14: OnNewsItemsAvailable
private void OnNewsItemsAvailable(IEnumerable<NewsItem> newsItems, object userState)
{
IEnumerable<NewsItem> orderedItems = newsItems.AsQueryable().OrderByDescending(i => i.PublishDate);
ViewActionResult result = View("List");
result.ViewData["Items"] = orderedItems.ToArray();
Task<ActionResult> task = (Task<ActionResult>)userState;
task.Complete(result);
}
示例15: FindResources
public void FindResources(string searchTerm)
{
string searchTermLower = searchTerm.ToLowerInvariant();
data = DataManager.Resources.Where(item => (item.Title.ToLowerInvariant().Contains(searchTermLower) || item.Tags.ToLowerInvariant().Contains(searchTermLower)));
results.ItemsSource = data;
this.DataContext = data;
OnSearchCompleted(new SearchEventArgs(data.AsQueryable()));
}