score:2
i think you want to use expression.andalso
(a short-circuiting and) on the two predicate expressions in question to construct the body of the expression-tree.
var body = expression.andalso(keyexists, valuecorresponds);
return expression.lambda<func<address, bool>>(body, datafields);
edit: (if you want to stick with your existing technique)
my guess is that your and
method is an extension-method from the linqkit library. if so, note that this extension involves 'invoking' the right-hand side expression with the parameters of the first expression as part of producing the result. if this isn't acceptable to you (linq provider limitations, perhaps?), you can use the useful expand
extension that also comes with this library to 'inline' the invoked expression.
return expression.lambda<func<address, bool>>(keyexists, datafields)
.and(expression.lambda<func<address, bool>>(valuecorresponds, datafields))
.expand();
but this is massive overkill in this case; my advice is to go with my first sample.
Source: stackoverflow.com
Related Query
- Dynamically compiling LINQ queries to verify a dictionary value
- LINQ - Convert List to Dictionary with Value as List
- Dynamically generate LINQ queries
- Linq Query Dictionary where value in List
- Building Dynamic LINQ Queries based on Combobox Value
- LINQ Source Code Available
- LINQ Sub-select from Dictionary based on value type
- how to change the value of dictionary using linq based on key?
- minimum value in dictionary using linq
- Select most frequent value and count using LINQ and assign to dictionary
- LINQ querying nested dictionary with multiple key value selection in C#
- Update a Dictionary value using Linq
- Return list with more than one value stored in a dictionary using linq
- creating Linq to sqlite dbml from DbLinq source code
- Does LINQ convert code to SQL queries
- C# - Code supposed to be unreachable when calculate value in LINQ sum method
- C# LINQ : Dynamically create property and values that includes sum of a value from a grouped query
- build linq queries dynamically
- LINQ filter by type on list from dictionary value
- Dictionary of dates and values, finding value of max date per year in LINQ
- how to remove half of the dictionary items based on value (DateTime) with LINQ in C#?
- Linq return WhereEnumerableIterator from Dictionary value matches?
- Dictionary from other dictionary grouping by object value field using linq
- How to get value from Dictionary to new Object in LINQ query
- Linq query for dynamically value
- Can't add a new record with an integer value into database by using linq from code C#
- How to dynamically get a property value in which is in another property with Linq where statement
- Get Dictionary value in IQueryable LINQ to Entities query
- How to dynamically build and store complex linq queries against a list of hierarchical objects?
- Remove multiple keys with same value data from dictionary in C# using Linq
More Query from same tag
- where can I find a good example of using linq & lambda expressions to generate dynamic where and orderby sql?
- Purpose of RemoveAll()
- LINQ ToList() serialization error?
- LINQ to SQL Associations Not Generating
- linq to entities - try this one!
- IServiceLocator.GetInstance<TService>() is not working
- How to get an element within an attribute using LINQ
- How to deal with parallel arrays in LINQ?
- Get a strongly typed list of unique items using LINQ GroupBy() from database
- Wrapping method to make it generic with map method
- ASP.NET Core Returning
- 'System.Type' does not contain a definition for 'GenericTypeArguments' with (dynamic)
- How to define my own LINQ construct in C#?
- Using EF to return specific formatted JSON from ASP.NET MVC
- Linq & Entityframework, ISNull and getting a single value from a join
- Rx.NET: Take until specified count or timer elapsed
- Linq expression for ILIst works in VB.Net but not C#?
- Add element to an XML file on Windows Phone
- How can i get all subnode values separately from XML Response using LINQ to XML?
- LINQ with Subquery/Group By/Join
- DoublyLinkedList C# Removelast two elements
- How to grouping list by a field and select into groups min of another field via linq?
- Query structure and syntax for multiple filtering options
- How do I "select null as "Column" Using LINQ in C#
- Generic parsing of Expressiontree to SQL
- replacing value only from an Xelement using linq
- How to discover financial Year based on current datetime?
- Get a random item from a collection that does not already exist in another collection - LINQ?
- using Expression Tree with Where Any EntityCore
- Get duplicates from C# List<object>