score:0
the list myitems
contains items of type object
where each this item is actually object[]
so we need to cast to object[]
first and then filter and select based on the searched certain number
.
string certainnumber = "1";
var myids = myitems
.where(o => ((object[]) o)[1].tostring() == certainnumber)
.select(o => ((object[]) o)[0].tostring());
the equality operator on strings performs an ordinal (case-sensitive and culture-insensitive) comparison
so change it in the where...
if you need some different kind of comparison in your case.
score:0
got it working and wanted to share the information:
var myids =
(from item in myitems.cast<object[]>()
select new
{ id = item[0], number = (string)item[1] }
)
.where(x => x.number == filtercondition)
.select(x => (string)x.id)
.tolist();
score:3
use select()
and where()
bool issatisfyingnumber(string number) {
// true if number satisfies some criteria
}
list<string> matchingids = myitems
.where(item => issatisfyingnumber(item[1].tostring()))
.select(item => item[0].tostring())
.tolist();
Source: stackoverflow.com
Related Query
- LINQ Source Code Available
- creating Linq to sqlite dbml from DbLinq source code
- source code for LINQ 101 samples
- c# Linq or code to extract groups from a single list of source data
- Convert string[] to int[] in one line of code using LINQ
- Code equivalent to the 'let' keyword in chained LINQ extension method calls
- Linq code to select one item
- How are people unit testing code that uses Linq to SQL
- LINQ query to perform a projection, skipping or wrapping exceptions where source throws on IEnumerable.GetNext()
- Syntax to execute code block inside Linq query?
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Best open source LINQ provider
- Is there a good source that gives an overview of linq optimizations?
- Does this LINQ code perform multiple lookups on the original data?
- How to understand the following C# linq code of implementing the algorithm to return all combinations of k elements from n
- LINQ WHERE method alters source collection
- Where can I view LINQ source code?
- Suggestions for designing complex LINQ code
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Left outer join using LINQ -- understanding the code
- How to pass LinQ Expressions from F# to C# code
- How to reuse a linq expression for 'Where' when using multiple source tables
- Avoiding code repetition when using LINQ
- Using LINQ to delete an element from a ObservableCollection Source
- How does linq actually execute the code to retrieve data from the data source?
- How can I switch that code to use LINQ
- How does this linq code that splits a sequence work?
- multiple orderby in this linq code
- How can I combine this code into one or two LINQ queries?
- Linq with where clause in many-to-many EF Code First object
More Query from same tag
- Object property is null after taking data from DB. Entity Framework
- Using Entity Framework 4 how to filter referenced Entity Collection
- How to set a value in one list when comparing it with other list using LINQ
- linq .Value Nullable Object must have a value. How to skip?
- Statement doesn't return all entities
- Calculate Average Age from a list of dates using linq
- XDocument Descendants of Descendants
- LINQ to Entities does not recognize the method 'System.String Decrypt(System.String, System.String)' method
- Join on compare keys on one side of equals (startswith)
- ASP.Net MVC error creating model for 2 linked tables
- linq string.contains on field of child object list
- Convert Left Outer join with 2 condition in relation to LINQ
- c# remove elements on a list by comparing with other lists
- How can i convert a Model.Tag (has Id and Name) to a "List of" Name?
- LINQ to Entities does not recognize the method ElementAt(i);
- Get weekday range from two dates
- Learning the Entity Framework
- Is there anything that is possible in LINQ but not Lambda?
- Using Where() with a dynamic Func fails, but works with a hard coded Where() clause
- MVC-How to Join Two Tables or Models using Linq ASP.NET MVC?
- Problem with Linq Joins with multible keys?
- Join and Group By using Lambda Expression
- Linq query for NOT IN on joined table
- Generic variadic parameters
- Linq create an array of Dto objects, with an array in it
- c# Replace string in a property of a class using linq not working
- Is it possible to replace this foreach loop with Linq?
- Many outer join with SQL to LINQ
- How to intersect two different object collections by specific property?
- Linq group by + where for each group