zzz projects Entity Framework 6 EF 6
Home EF Core Articles Knowledge Base Online Examples
  • Home
  • EF Core
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework 6 - Knowledge Base (KB)

65 results in tag: expression-trees

What is the best way to create a Linq Expression Tree that compares to 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

Within a generic extension method, how do I apply OrderBy to an IQueryable using a string column name?

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

Where Predicate Type Arguments in C#

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

Parent Navigation Property C# Expression Tree Parameter

How can I create a ParameterExpression for the parent side of a 1 to * Navigation Property?...The following works for the child entity:...var parameter = Expression.Parameter( typeof(T), // where T is the entity type GetParameterName()); // helper...
c# entity-framework expression-trees lambda
asked by blu

To pick an anonymous type, establish a LINQ Expression Tree.

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 may Entity Framework be wrapped to intercept LINQ expressions right before they are executed?

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

When invoking a method-provided expression on a member property, LinqKit throws an InvalidCastException.

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

In Expression Trees, working with nullable types

I have an extension method to dynamically filter Linq to Entities results using string values. It works fine until I use it to filter nullable columns. Here's my code:...public static IOrderedQueryable<T> OrderingHelperWhere<T>(this IQueryable<T> source, ...
c# entity-framework expression-trees lambda linq
asked by dstr

Expression Tree's like operator

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

Unable to construct a constant variable of type †System.Objectâ€TM in Entity Framework - Linq. There are only primitive kinds.

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

I'm dialing the number. Any Entity Framework Extension Method that uses 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 can I generate an expression tree for a query by reflecting over T?

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

Nullable Types and Expression Trees

I've been playing around with Expression Trees. I have the following simple method that performs a query by dynamically creating an Expression Tree. ItemType is a nullable int in the database, ...and also in the EF entity class.... For some reason thou...
c# entity-framework expression-trees
asked by Adam Rackis

In Expression Trees, why is a conversion required?

From ...this question... I asked 5 minutes ago, it's clear that the following code throws an exception, stating that ...Unhandled Exception: System.InvalidOperationException: The binary operator Equal is not defined for the types 'System.Nullable`...
c# entity-framework expression-trees
asked by Adam Rackis

How do you set the value of an IQueryableTproperty? >'s

I'm using Entity Framework 4.1 Code First. In my entity, I have three date/time properties:...public class MyEntity { [Key] public Id { get; set; } public DateTime FromDate { get; set; } public DateTime ToDate { get; set; } [NotMap...
entity entity-framework expression-trees iqueryable linq
asked by Matt Johnson-Pint

For the maximum date value, an expression tree must be built.

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 do you put this together: 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

The Entity Framework has reached its 2100 parameter limit.

I'm migrating some of our code from LINQ-to-SQL to Entity Framework. Previously, when run up against a 2100 parameter limit from SQL Server (described ...here...), I used the solution provided by Marc Gravell ...here.... As stated in his own response, it ...
entity-framework expression-trees linq parameters sql
asked by Ocelot20

How to use Expression Tree to build dynamic conditions

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

Complex mappings are used to translate an expression tree from one type to another.

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

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...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Save your entities 20× faster with EF Extensions
SaveChanges vs BulkSaveChanges

EF Extensions
Try for free now
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!