All Questions
Tagged with linq-expressions linq-to-entities
42 questions
2
votes
1
answer
91
views
How add MemberInitExpression into Bindings other Lambda MemberInitExpression
I have the following classes:
class Source {
public int Id { get; set; }
public string Name { get; set; }
public SourceItem Item { get; set; }
}
class SourceItem {
public Guid Id { ...
2
votes
0
answers
56
views
EF6 generates WHERE clause in unexpected order
I'm using the solution from this answer to form an Expression<Func<Proposal, bool>> object (where Proposal is an entity type in my app), according to the searching criteria input on a ...
0
votes
1
answer
210
views
Write an extensions method for linq and entity framework
I have a little odd question working by lifting an very old system and replacing 10year old nHibernate with EF. I have trouble formulating some linq extensions for a search page.
The thing I want to ...
2
votes
1
answer
413
views
In LinqToEntities, How to pass dynamic column name to DbFunctions.Like
I have an IQueryable<T> from my DbSet in Entity Framework. I am provided a "Fuzzy Search String", named searchText, like so:
public List<T> Search<T>(string searchText)
{
using ...
0
votes
1
answer
167
views
Modifying lambda Expression<Func<TOuter, TInner, TResult>> to Expression<Func<a', TResult> in an LINQ to Entities safe way
At the bottom is an example of a left join implementation. It will work for normal lists and arrays but it will not work with LINQ to entities since I use Expression.Invoke().
What I'm trying to ...
1
vote
2
answers
479
views
Proper way to query DataContext using Group by that has fields with Nulls
I'm using Entity Framework, And I'm querying the Data using a Group By clause. In the Group by there are multiple columns that have to be used. Some of the columns can have nulls. The issue is that ...
1
vote
2
answers
407
views
Create a Linq to entities IQueryable extension for date grouping (GroupBy)
I am trying to build an expression tree for a custom grouping by date, transform this:
groupedData = entity.GroupBy(e => new DateTime(e.created_date.Year, 1, 1));
Into an extension that does not ...
1
vote
1
answer
630
views
Expression.Bind with Condition
I have an entity which contains a collection of other entity (among others)
public class A{
public ICollection<B> Bs {get;set;}
}
I want to implement dynamic lambda expression which will ...
0
votes
0
answers
264
views
Using a function defined as a Linq.Expression in VB.NET
I found this question's accepted answer very informative to use Expressions with Linq to Entities. I can't figure out the VB.NET syntax, however.
Given something like (this part being in C# is fine)
...
10
votes
1
answer
3k
views
System.Core error: "Code supposed to be unreachable" using C# Entity Framework and Linq with Expression
I'm getting a "Code supposed to be unreachable" error when executing the following Linq to Sql statement. I'm using EF 6.1.3. I think this is a known bug related to filtering a navigation property. It ...
1
vote
1
answer
170
views
How can I get Property Expression for field of a property
I'm using Entity Framework 6. I have 2 classes:
public class BookingRecord
{
public int Id {get; set;}
public int CustomerId {get; set;}
[ForeignKey("CustomerId")]
public virtual ...
0
votes
1
answer
152
views
How to pass Func to a class which encapsulates the Expression based on that Func?
I have class DropdownFilter which has:
private readonly Func<TEntity, string> fieldWhichMustEqualValue;
public override IQueryable<TEntity> Filter(IQueryable<TEntity> ...
1
vote
1
answer
80
views
Is there a way to more easily combine Expressions and lambdas?
Let's say I have an Expression<Func<Foo, Bar>> calculateBar which 'reduces' a Bar into a Foo, which I can use like so:
IQueryable foo = getFoos();
bars = foo.Select(calculateBar);
However,...
-1
votes
2
answers
282
views
Is it possible to simplify this LINQ expression for Entity Framework?
I'm implementing a basic search service, and several different repositories are injected into it. The repositories have a method that allows for an expression to be used like so:
public ...
1
vote
1
answer
872
views
LINQ Expression for CROSS APPLY two levels deep
Fairly new to LINQ and am trying to figure out how to write a particular query. I have a database where each CHAIN consists of one or more ORDERS and each ORDER consists of one or more PARTIALS. The ...