score:0
is this what you want?
func<model, string> p = s => s.name;
var query = data.where(s => an_array.contains(p(s))).distinct().tolist();
score:0
i think what you want is any
, rather than contains
. one of the overloads takes a predicate that you can use to test for a specific condition:
public void getfiltereditems<t>(func<t, bool> predicate)
{
var queryresult = data.where(s => an_array.any(predicate)).distinct().tolist();
}
Source: stackoverflow.com
Related Query
- Is there a way to parameterize the Contains portion of Linq when linked to an array
- Is there any way to create a LINQ query as a variable without having the data source (yet)?
- Is there a way to speed up the contains extension in a LINQ query for large datasets?
- Is there a way I can do a foreach that contains code in a LINQ expression?
- Is there a way to capture the index value in a LINQ Where method in C#?
- Is there a way to get the SQL created by a LINQ query?
- Is there any way to use Linq to SQL without adding the .dbml file?
- When selecting an anonymous type with LINQ from EF, is there no way to run a method on an object as you select it?
- Is there an easy way to append lambdas and reuse the lambda name in order to create my Linq where condition?
- c# linq generated query length over the limit. Is there any way we could up lift this limit?
- Is there a way to create an Linq XElement iterator that is updated as the tree is modified?
- Is there a better way to do this, maybe replace the for/foreach loop with something LINQ ish?
- LINQ to objects: Is there a way to pass to LINQ the accessor from which to get values?
- If you have a LINQ statement using the Select() method, is there a way to get a value from the next record?
- Is there a secret to using LINQ to SQL to add records when the object has relationships?
- Is there a way to track when a Data Context hits the database?
- Is there a way to add or remove a line of an LINQ to DB Query based on if the value being checked is null?
- Is there a way to parameterize method in a linq query?
- How can I check the number of calls to the database in LINQ query when using .NET Core and Code First?
- What is the correct way to Take() X-number of records with LINQ but find out if there are more
- LINQ to SQL - is there a way to get a 'preview' of the database with changes made to a context?
- How can I use a predicate in a crm sdk 2011 linq query when the query contains a join?
- Efficient way to be updating child records when updating the Master table using Linq
- Is there a way I can defer the .Where clause in a LINQ statement?
- LINQ entity data model generated code error - The type 'DBContexts.Category' already contains a definition for 'ID'
- The source contains no DataRows using Linq
- Is there a way to re-use a LINQ statement, but alter the property and method being called on that property?
- Is there a more compact way to select an element property in LINQ when .FirstOrDefault returns null - without it throwing an exception?
- Is there a better way to code this LINQ fragment?
- Is there a way in linq wherin i can insert a row(from dictionary) in datatable using the list of column names c#?
More Query from same tag
- Query a list of objects that contains any string
- How to rename the datatable column name without losing the data?
- Transform Sql to EF Core Linq query
- C# Join by Linq how should pass innerKeySelector?
- How to return empty string if an object is null?
- Find an XElement with a certain attribute name and value with LINQ
- C# Trying to avoid duplicates
- LINQ: Select <contition> OR <condition>
- Passing Aggregation to a Linq Query
- TakeWhile, but get the element that stopped it also
- Code First Entity Framework, select ViewModel - constructor with parameter
- How to optimize this LINQ expression?
- Dynamic Linq Query with multiple select value's
- What would be a good way to add "friendly" column names to a LINQ to SQL model?
- LINQ Find Null Objects in List
- How to sort and output data stored in a list
- SQL "IN" CLAUSE Performance issue
- Binding and Updating LINQ object in Gridview
- How to Group Data by week in Linq
- LINQ with EF6: Losing second reference in two column table
- Convert from LINQ to SQL query to SQL query
- Select a field that is not in Group By clause in LINQ
- IQueryable does not contain a definition for 'Select'
- Dynamically set list object type in c#
- Creating a compiled query linq and performance issues with regular LINQ
- Call query which displays odata information with ajax
- Use Expression<Func<MyEntity, bool>> in Linq on MyEntity.<OtherEntity>.<MyProperty>
- I want to get 2 values returned by my query. How to do, using linq-to-entity
- LINQ Sum for given range of dates data
- How do I create a dynamic Linq query to fill an ASP.NET databound ListView?