score:0
no, each query is executed independently, and all you're left with is the result set of the query itself. there is nothing within the memory object that contains the original collection nor any accessible reference to the original collection. considering that the original collection may now be null or out of scope, this would be dangerous to allow even. if you need to the original collection, you will need to keep it in scope until you're completely finished with it.
score:0
this is cheating, but maybe it makes sense in your context:
interface ireferencedqueryable<t> : iqueryable<t>
{
ienumerable<t> source { get; }
}
static class ireferencedqueryableextensions
{
public static ireferencedqueryable<t> asreferencedqueryable<t>(
this ienumerable<t> source)
{
return referencedqueryable.from(source);
}
class referencedqueryable<t> : ireferencedqueryable<t>
{
public ienumerable<t> source { get; private set; }
referencedqueryable(ienumerable<t> source)
{
source = source;
}
static ireferencedqueryable<t> from(ienumerable<t> source)
{
return new referencedqueryable(source);
}
// all the iqueryable members would be
// implemented through asqueryable()
// ...
}
public static ireferencedqueryable<t> where<t>(
this ireferencedqueryable<t> source,
expression<func<t, bool>> predicate)
{
return referencedqueryable.from(
((iqueryable<t>)source).where(predicate));
}
// do the same for all the linq extension methos you want to support
}
you would use it like this:
t[] itemarray = // initialized values
var itemquery = itemarray.asreferencedqueryable()
.where(*/some query*/)
.skip(5)
.etc() ...
when you need your source sequence you can access it through the source
member, possibly through an as
cast.
var s = itemquery.source;
score:3
the iqueryable
most likely does have a reference to the underlying collection (possibly through a number of layers of indirection), but it won't be publicly exposed, so you won't be able to access it, at least not in any way that i would consider reasonable and not a very, very messy hack.
Source: stackoverflow.com
Related Query
- How to get original collection from an IQueryable<T>
- How do I get the latest date from a collection of objects using LINQ?
- How to get leaf node from a nested collection using lambda expression
- How to get list for a property of a class from its collection
- How to get strongly-typed collection from XML using Linq
- C# LINQ How to get a data source from a db?
- How can I get the top three players and their high scores from a collection using linq and lambdas
- How do I get the first value from this collection using Linq to Entities?
- How to get the second repeated item from a collection of objects using LINQ to object
- how to get specific collection from a collection with linq?
- How to get elements from collection A that not in collection B? i.e. A-B
- C# Linq- How to get distinct collection from a collection
- How to Get a Object from IEnumerable collection using LINQ Lambda?
- How to get last row + column from a collection in C# using lambda
- How to get the whole record from a collection which has latest dateTime using linq?
- C# LINQ or for loop How to get a data source from a db?
- how can i get a collection from an item in another collection that is also a collection
- How to get duplicates DataColumns from a List Collection C#
- How do I get the object with the second latest date from a collection of objects
- How to get key value pair from appSettings into a collection of SelectListItem?
- How can I get the following collection to return the original type?
- How to get enumerable or collection of values from WhereSelectListIterator
- How to get only unique nodes from a collection - IEnumerable<XNode>
- How to get values from IGrouping
- How to get duplicate items from a list using LINQ?
- How can I get every nth item from a List<T>?
- How do I get a distinct, ordered list of names from a DataTable using LINQ?
- How to get a distinct list from a List of objects?
- How to get the closest number from a List<int> with LINQ?
- How to get first object out from List<Object> using Linq
More Query from same tag
- Linq query - reading nested XML to dictionary
- Replace in a list of strings using LINQ
- Performing a JOIN in LINQ with a strongly-typed object
- SortedSet<string> Linq .Except with Comparer strangeness
- How to roll back queries in C#?
- XML replace value with Linq
- How do i filter one list from another list using linq
- Filter an IQueryable with case insensitive.
- How to create more accurate searching?
- How to: Use async methods with LINQ custom extension method
- Selecting only unique values from collection
- Get WPF combobox SelectedItem property and assign to a string variable in c# using MVVM pattern
- LINQ to Entities does not recognize the method ..., and this method cannot be translated into a store expression
- How to Sort a Model Based on a Property in IList<T> within that Model
- LINQ newbie question for 2 dimensional set
- LINQ to dictionary with multiple keys for a single value
- LINQ intersect?
- what does "non-filtering clauses" mean when running linq on parse.com?
- Exception thrown Getting items from group using fluent api
- Using InvokeMember on a nestedProperty in C#
- Generic extension methods in LINQ
- Search a list inside a list in Linq
- How to get extreme leaf node against heights parent in self referencing linq
- How do I get the objects from a list of objects which contain a duplicate property inside of another list in the object?
- Ordinal Position of Element in IENumerable Collection (Linq to XMl )
- How to convert an IGroupedObservable to IGrouping?
- Two GroupBy's on LINQ query
- Linq IList interfaces vs concrete
- C# joined lists. LINQ. unable to create a constant type
- Why does Enumerable.Single() iterate all elements, even when more than one item has already been found?