Filtering this Linq query?

MainView. DataSource = organizedData. Where(x => x.

Custom == "*").ToList().

Amazing. Yes, thank you. The .

Where function -- I now see its proper usage. – Sean Glover Aug 8 at 21:37 This works fine but it's more readable to put the Where clause right in the linq query. And that's the whole point of linq :P – Brian Gordon Aug 8 at 22:00.

I think this is what you're looking for. I put the value in a temp variable so it doesn't have to be computed twice. Var organizedData = from x in queryData group x by x.

StringID into xg let temp = xg. SingleOrDefault(x => x. Language == languageBox.SelectedItem.ToString()).

LanguageData where temp == "*" select new { StringID = xg. Key, English = xg. SingleOrDefault(x => x.

Language == "ENGLISH_US"). LanguageData, Custom = temp, }.

1 you're using xg before it is declared... – Thomas Levesque Aug 8 at 21:45 @Thomas thanks, fixed it – Brian Gordon Aug 8 at 21:59.

I think this is what you're looking for. I put the value in a temp variable so it doesn't have to be computed twice.

The use of yield has an interesting benefit which is that the query is not actually evaluated until it is iterated over, either with a foreach statement or by manually using the underlying GetEnumerator and MoveNext methods. This deferred evaluation allows queries to be kept as IEnumerable-based values that can be evaluated multiple times, each time yielding potentially different results. For many applications, this is exactly the behavior that is desired.

For applications that want to cache the results of query evaluation, two operators, ToList and ToArray, are provided that force the immediate evaluation of the query and return either a List or an array containing the results of the query evaluation. The query is evaluated each time the variable ayes is iterated over. Both ToArray and ToList force immediate query evaluation.

The same is true for the standard query operators that return singleton values (for example: First, ElementAt, Sum, Average, All, Any). The same deferred execution model is usually desired for data sources that implement the query functionality by using expression trees, such as LINQ to SQL. These data sources can benefit from implementing the IQueryable interface for which all the query operators required by the LINQ pattern are implemented by using expression trees.

Each IQueryable has a representation of "the code needed to run the query" in the form of an expression tree. All the deferred query operators return a new IQueryable that augments that expression tree with a representation of a call to that query operator. Thus, when it becomes time to evaluate the query, typically because the IQueryable is enumerated, the data source can process the expression tree representing the whole query in one batch.

As an example, a complicated LINQ to SQL query obtained by numerous calls to query operators may result in only a single SQL query getting sent to the database. The benefit for data source implementers of reusing this deferring functionality by implementing the IQueryable interface is obvious. To the clients who write the queries, on the other hand, it is a great advantage to have a common type for remote information sources.

Not only does it allow them to write polymorphic queries that can be used against different sources of data, but it also opens up the possibility for writing queries that go across domains.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions