score:0
Accepted answer
protected override iqueryable<entity> applywhereclause(iqueryable<entity> entities)
{
return entities.where(/* insert your extra where clause here */);
}
score:0
protected iqueryable<entityresult> getentities(etbdatacontext pcontext)
{
var q = pcontext.entities
.where(e => e.statuscode == "published")
.where(e => getwherecondition(e))
.orderbydescending(e => e.publishdate)
.select(e => new entityresult
{
name = e.name,
link = e.link
});
}
protected virtual expression<func<entity, bool>> getwherecondition(entity e)
{
return e => e.othercolumn == "othervalue";
}
score:3
protected iqueryable<entityresult> getentities(etbdatacontext pcontext)
{
return (from e in pcontext.entities
where e.statuscode == "published"
//is there a way to add a dynamic where clause here?
//i would like to ask the inherited class for it's input:
&& e.othercolumn == "othervalue" // <-- like getwhere(e)?
//without having to select the column
orderby e.publishdate descending
select e).firstordefault();
}
Source: stackoverflow.com
Related Query
- IQueryable where clause overriden in inherited class
- Building a dynamic where clause for dynamic keywords or using IQueryable C# Linq
- Where clause not working on LINQ IQueryable query
- How to call a method in the where clause of a LINQ query on a IQueryable object
- How to negate a Where clause of an IQueryable
- Mapping IQueryable where clause from DTO to Entity
- How to get the where clause from IQueryable defined as interface
- IQueryable where clause
- How to extract a where clause expression tree from IQueryable
- Where clause on field outside Lambda expression class in Linq
- Sum a IQueryable Column with where clause
- LINQ where clause using Generic IQueryable source
- Add Where clause to IQueryable
- Adding a LINQ where clause to a custom class
- How to call a function inside a where clause of IQueryable
- IQueryable where clause generated from list that needs to be OR'd together
- Where IN clause in LINQ
- Linq: adding conditions to the where clause conditionally
- Multiple WHERE clause in Linq
- LINQ to SQL Where Clause Optional Criteria
- Dynamic WHERE clause in LINQ
- C# Linq where clause as a variable
- Add the where clause dynamically in Entity Framework
- How to dynamically add OR operator to WHERE clause in LINQ
- If condition in LINQ Where clause
- How to select array index after Where clause using Linq?
- LINQ: adding where clause only when a value is not null
- IQueryable OfType<T> where T is a runtime Type
- lambda expression join multiple tables with select and where clause
- LINQ Join Where Clause
More Query from same tag
- LINQ how to return group by as List?
- Select from two indexing lists, create list of new objects
- arithmatic operation in linq using entity framework mvc C#
- Dynamic joins in Linq according to the Select & Where Clause
- It makes any difference to write linq with the where clause on top or on bottom
- Getting maximum date and return default date when table is empty
- Linq to populate values of a class
- Linq Select into New Object Performance
- Findall items in one list matching items in another list's VB.Net
- must have an IF in my Repeater
- How can I combine this code into one or two LINQ queries?
- Need to build expression tree for max date value
- LINQ - NOT selecting certain fields?
- What is wrong with my XDocument save?
- query a class object using linq
- How to write a LINQ query that will return list of entities whose ID is included in specific list?
- Is there a good LINQ way to do a cartesian product?
- Hanging Linq query with Guid.Empty in the where expression
- Update existing row mysql linq
- LINQ's deferred execution, but how?
- using multiple IEnumerable Joins
- Where IN clause in LINQ
- Extending a correlated Subquery to include another query in LINQ
- Add string items from array to a list of object
- Object reference updating, update all collections property?
- Update at the same time for 2 tables based on Keeping Event: Sorting of Jquery
- Count embedded documents mongodb c# LINQ
- How can I perform a nested Join, Add, and Group in LINQ?
- Compare 2 lists with different values
- C# Conditional Linq query to get value inside parenthesis