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

Expression Tree Tutorial - Knowledge Base (KB)

19 results for: in tag: linq-to-entities

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

Querying Entity with LINQ using Dyanmic Field Name

I have created a dynamic search screen in ASP.NET MVC. I retrieved the field names from the entity through reflection so that I could allow the user to choose which fields they wanted to search on instead of displaying all fields in the view....When the ...
c# dynamic-linq expression-trees lambda linq-to-entities
asked by Scott Lance

IQueryable: Creating dynamically an OR filtering

I have a set of search criterias in this form:... member | value | operator --------+---------+--------- height | 10 | > height | 2 | < name | Carl | == ...And I want to query all the objects that match any of these cri...
c# expression-trees iqueryable linq linq-to-entities
asked by SDReyes

Linq: Dynamic Query Contruction: query moves to client-side

I've been following with great interest the converstaion here:...Construct Query with Linq rather than SQL strings...with regards to constructing expression trees where even the table name is dynamic....Toward that end, I've created a Extension method, ad...
dynamic-linq expression-trees lambda linq linq-to-entities
asked by donundeen

Custom expression

I found this example code:...public IQueryable<T> Get<T>(ObjectSet<T> obj) where T : class { Type type = typeof(T); var x = type.GetInterface("IMyInterface"); if (x != null) { var property = type.GetProperty("MyStringField"); ...
c#-4.0 expression-trees linq-to-entities
asked by bit

How to obtain ToTraceString for IQueryable.Count

I use ...((ObjectQuery)IQueryable).ToTraceString()... to obtain and tweak SQL code that is going to be executed by LINQ....My problem is that unlike most IQueryable methods IQueryable.Count as defined like this:... public static int Count(this IQueryab...
c# expression-trees lambda linq linq-to-entities
asked by alpav

Unable to refactor using LINQ to Entities and LinqKit / PredicateBuilder

I have been trying to refactor a LINQ expression into a method, and have been running into both the "...Internal .NET Framework Data Provider error 1025...." and "...The parameter 'xyz' was not bound in the specified LINQ to Entities query expression...."...
entity-framework-4 expression-trees linqkit linq-to-entities predicatebuilder
asked by danludwig

Need help creating an expression tree for Where clause

I need to create an expression tree, which I can pass along as ...predicate... argument in ...Where... clause to Linq To Enities query....public static IQueryable<TSource> Where<TSource>(this IQueryable<TSource> source, Expression<Func<TSource, bool>>...
c# expression-trees linq-to-entities
asked by Trainee4Life

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

Building a custom predicate to act as a filter using a foreach loop

I need to filter a list of documents by passing them to a custom filter that I'm struggling to ...build dynamically... using a ...foreach... loop :...var mainPredicate = PredicateBuilder.True<Document>(); // mainPredicate is combined to other filters suc...
c# expression-trees linq-expressions linqkit linq-to-entities
asked by user2324540

Combine select clauses in linq to entities with anonymous types

How can i combine select clause in linq to entities in order to project into an anonymous type?... Assume that I have these entities:...public class Address { public string City { get; set; } public int ZipCode { get; set; } //other properties...
.net anonymous-types c# expression-trees linq-to-entities
asked by Joachim B

Build Dynamic Select using Expression Trees

How would I generate the following using expression trees......var people = context.Set<Person>(); var transactions = context.Set<FinancialTransaction>(); var dataview = people.Where( p => p.LastName == "Smith" ); var selection = dataview .Selec...
c# entity-framework expression-trees linq-to-entities webforms
asked by David Turner

Extract piece of lambda for expression in select

I can extract and reuse entire expression like that:...Expression<Func<User, int>> userExpression = x => x.Roles.Count() ...but is it possible to extract some how only ...x.Roles.Count()... part and use that in context of ...Expression<Func<User, T>>...Th...
c# expression expression-trees lambda linq-to-entities
asked by Vladimirs

How can I convert Linq to Entities Query into expression tree?

Say I have the following query how can I get the base Expression Tree? ...MyContext.Items.Select(i=>i.Color); ...I want to get the expression tree of this so that I can then use the expression tree to dynamically set what property is being selected (So I ...
c# expression-trees linq linq-to-entities
asked by user2125348

LINQ to Entities OrderBy Expression Tree

I am trying to write a LINQ query to orderBy a dynamic property given by a string value....Here is what my original code was:... Expression<Func<T, dynamic>> orderBy = i => i.GetType().GetProperty("PropertyName").GetValue(null); ...When I tried to run thi...
c# entity-framework-6 expression-trees linq linq-to-entities
asked by Seth Denburg

Convert MemberExpression to string

In the following method I'm trying to make an Expression using the ...List<string>().Contains()... method....The problem is that the value I need to check if exists in the list is not of type string and therefore I need to convert it....private static Exp...
c# expression expression-trees linq-to-entities
asked by Nicholas Magnussen

Query and map complex objects

My goal is to query and map complex objects with as little overhead as possible. I am working with a large database with lots of related tables. I am trying to use LINQ select and projection to select only the necessary information i need to make the obje...
.net c# expression-trees linq linq-to-entities
asked by Moe

C# 7.0 Value Tuple compile error?

When I am trying to compile the following code:...var post = iPostService.GetAll().Select(x => (x.Title, x.Author)); ...I get the compiler error: 'An expression tree may not contain a tuple literal.'...So I also tried this: ...var post = iPostService.GetA...
asp.net c#-7.0 expression-trees linq-to-entities valuetuple
asked by Tấn Sang

How to get dynamic predicate using expressions when joining in Linq

I wrote a static method which will give appropriate predicate lambda using expression api for different type of fields....static Func<T, bool> Process<T>(string type) { ParameterExpression parameter = Expression.Parameter(typeof(T)); Expression p...
c# expression-trees lambda linq linq-to-entities
asked by murali KRISHNA

Page 1 of 1
  • 1

Prime Library

Performance

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

Expression Evaluator

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