zzz projects Expression Tree Tutorial
Getting Started Documentation Knowledge Base
  • Getting Started
  • Documentation
  • Knowledge Base

Expression Tree Tutorial - Knowledge Base (KB)

66 results for: in tag: entity-framework

How do I build a Linq Expression Tree that compares against a generic object?

I have an IQueryable and an object of type T....I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName))...so ......public IQueryable<T> DoWork<T>(string fieldName) where T : EntityObject { ... T...
c# entity-framework expression-trees generics linq
asked by JTew

How do I apply OrderBy on an IQueryable using a string column name within a generic extension method?

public static IQueryable<TResult> ApplySortFilter<T, TResult>(this IQueryable<T> query, string columnName) where T : EntityObject { var param = Expression.Parameter(typeof(T), "o"); var body = Expression.PropertyOrField(param,columnName); var sor...
.net c# entity-framework expression-trees linq
asked by JTew

C# LINQ Where Predicate Type Arguments

I have an XElement with values for mock data. ...I have an expression to query the xml:...Expression<Func<XElement, bool>> simpleXmlFunction = b => int.Parse(b.Element("FooId").Value) == 12; ...used in:...var simpleXml = xml.Elements("Foo").Where(si...
c# entity-framework expression-trees lambda
asked by blu

How to create LINQ Expression Tree to select an anonymous type

I would like to generate the following select statement dynamically using expression trees:...var v = from c in Countries where c.City == "London" select new {c.Name, c.Population}; ...I have worked out how to generate...var v = from c in ...
c# entity-framework expression-trees linq linq-to-entities
asked by Tom Deloford

How to wrap Entity Framework to intercept the LINQ expression just before execution?

I want to rewrite certain parts of the LINQ expression just before execution. And I'm having problems injecting my rewriter in the correct place (at all actually)....Looking at the Entity Framework source (in reflector) it in the end comes down to the ...
c# entity-framework expression-trees linq
asked by Davy Landman

LinqKit System.InvalidCastException When Invoking method-provided expression on member property

Given a simple parent/child class structure. I want to use linqkit to apply a child lambda expression on the parent. I also want the Lambda expression to be provided by a utility method....public class Foo { public Bar Bar { get; set; } } public cl...
c# entity-framework expression-trees linq linqkit
asked by user293499

Like operator in Expression Tree

I have a Linq extension method to dynamically filter Linq queries using string values. For example: ...query.WhereHelper("columName", ">", 1).... I could use many different filter operators like GreaterThan or NotEqual etc. but not "Like". There is no Exp...
.net entity-framework expression-trees lambda linq
asked by dstr

Entity Framework - Linq - Unable to create a constant value of type ‘System.Object’. Only primitive types

I have a method to build an expression for a linq query for a given type, property, and value. This works wonderfully as long as the property on the type is NOT nullable. Here is the example I am working from (...http://www.marcuswhitworth.com/2009/12/dyn...
entity-framework expression-trees linq
asked by Shane

Calling the .Any Extension Method with Entity Framework using Expression Trees

I have looked at few examples here ...Calling a Method from an Expression... and on ...MSDN... but I have not been able to get the right method call/object type for Any() for the query below. I seem to be able to get the property call but not IEnumerable ...
c# entity-framework expression-trees
asked by RCrabtree

How to reflect over T to build an expression tree for a query?

I'm trying to build a generic class to work with entities from EF. This class talks to repositories, but it's this class that creates the expressions sent to the repositories. Anyway, I'm just trying to implement one virtual method that will act as a base...
c# entity-framework expression-trees linq reflection
asked by Gup3rSuR4c

Need to build expression tree for max date value

I'm trying to build an expression tree for this linq query: so I can pass in a generic Entity:...this.EntityCollection.Select((ent) => ent.TimeStamp).Max() ...I am wanting to create a class that takes a generic Entity and finds the max of its TimeStamp pr...
.net c# entity-framework expression-trees linq
asked by Adam

How compose Expression: selector + predicate?

Assume that we have two classes...public class EntityA { public EntityB EntityB { get; set; } } public class EntityB { public string Name { get; set; } public bool IsDeleted { get; set; } } ...And two expressions for selector and predicator..
entity-framework expression-trees lambda linq
asked by qmicron

How to create dynamic condition using Expression Tree

Please consider this code:...System.Linq.Expressions.Expression<Func<tbl, bool>> exp_details = r => r.ID_Master == Id && r.Year == Year && r.Month == Month ; ...I want to write a function that expect some argument, and then retrieve some data from my data...
c# c#-4.0 entity-framework expression-trees linq
asked by Arian

Translating expression tree from a type to another type with complex mappings

inspired by ...this answer... I'm trying to map a property on a model class to an expression based on the actual entity. These are the two classes involved:...public class Customer { public string FirstName { get; set; } public string LastName { g...
asp.net-web-api entity-framework expression-trees linq
asked by Kralizek

Generic expression for where clause - "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities."

I am trying to write a really generic way to load EF entities in batches, using the Contains method to generate a SQL IN statement. I've got it working if I pass the entire expression in, but when I try to build the expression dynamically, I am getting a...
entity-framework expression-trees generics linq linq-to-sql
asked by Randar Puust

Build a nested lambda Expression Tree for an Entity Framework Many to Many relationship?

I am trying to build an Entity Framework 4 Many to Many relationship filter, this is for a Dynamic Data project. I know that I need to build an Expression Tree at run time, and I am familiar with doing this for something like a simple where expression li...
.net entity-framework expression-trees linq many-to-many
asked by Brian Tax

How to convert from Expression<Func<DomainType>>predicate to Expression<Func<DTOtype>predicate

Some background: I have in my application multiple layers, two of which are a domain layer and an infrastructure layer which serves as my DAL. In the domain layer, I have implemented a generic repository pattern as such:... public interface IRepository...
automapper domain-driven-design entity-framework expression-trees linq
asked by John Pool

Generate dynamic select lambda expressions

I am somewhat new to expression trees and I just don't quite understand some things....What I need to do is send in a list of values and select the columns for an entity from those values. So I would make a call something like this:...DATASTORE<Contact> d...
entity-framework expression-trees lambda linq-to-entities
asked by cjohns

List of Expression<Func<T, TProperty>>

I'm searching a way to store a collection of ...Expression<Func<T, TProperty>>... used to order elements, and then to execute the stored list against a ...IQueryable<T>... object (the underlying provider is Entity Framework). ...For example, I would like...
.net c# entity-framework expression-trees lambda
asked by Bidou

Best way to concat strings and numbers in SQL server using Entity Framework 5?

For some reason Microsoft decided to not support simple concat in EF5....e.g....Select(foo => new { someProp = "hello" + foo.id + "/" + foo.bar } ...This will throw if foo.id or foo.bar are numbers....The workaround I'v...
c# entity-framework entity-framework-5 expression-trees
asked by Roger Johansson

Page 1 of 4
  • 1
  • 2
  • 3
  • 4
  • »

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...