I am desperately trying to use LinqKits PredicateBuilder to allow the user to enter a search term into a text box and return records from two database tables/entitysets but I'm struggling to get anywhere. The (simplified) database structure is as follows:
Person Alias
------ ------
A_I...
I am using PredicateBuilder, which means that I am using the AsExpandable extension method. The problem is that I can no longer Trace my SQL queries as the following error is thrown when I try to cast the query to ObjectQuery so that I can do a ObjectQuery.ToTraceString() call on it...
Unable to cast object of type 'LinqKit.ExpandableQu...
I have recreated the Predicatebuilder class in a seperate C# project and I'm trying to use it in a VB.NET project but I keep getting the following error:
Overload resolution failed because no accessible 'Or' accepts this number of arguments.
when I use it like so:
Dim predicate = PredicateBuilder.False(Of t_Quote)()
predicate = pr...
Im using the PredicateBuilder as seen here http://www.albahari.com/nutshell/predicatebuilder.aspx, everything works great, and now i can genrate Dynamic LINQ to SQL expressions, but the thing that i dont understand is why when i am on a loop like this:
var inner = PredicateBuilder.False<MyType>();
foreach (var f in Filtermodel.Instrumen...
I'm trying to use the Predicate from Albahari to create a TSQL statement like:
select * from channel
where channel.VendorID IN (@vendorIDs)
AND channel.FranchiseID IN (@franchiseIDs)
or a predicate like : c => (c.VendorID = x || c.VendorID == x2 ...) && (c.FranchiseID == f || c.FranchiseID == f2 ...)
but I'm having troubles. Here is ...
I have a 1 : M relationship.
I built a dynamic query based on input from users to return the listing of parents entities along with their children (using predicate builder:
(done successfully new TDataContext().Ps.Where(predicate) )...
but need to order the results by a field found only on the child entities.
I'm at a loss: new TDat...
I previously asked a question about chaining conditions in Linq To Entities.
Now I use LinqKit and everything works fine.
I want to see the generated SQL and after reading this answer, I use LinqPad.
This is my statement:
var predProduct = PredicateBuilder.True<Product>();
var predColorLanguage = PredicateBuilder.True<ColorLanguage>();...
I am trying to select rows from a table where one of the (NVARCHAR) columns is within a numeric range.
SELECT ID, Value
FROM Data
WHERE ISNUMERIC(Value) = 1 AND CONVERT(FLOAT, Value) < 66.6
Unfortunately as part of the SQL spec the AND clauses don't have to short circuit (and don't on MSSQL Server EE 2008). More info: http://stackover...
I have two tables (TABLE1, TABLE2 - unique i know) that has a 1-to-many relationship respectively and a foreign key between ID columns of both tables.
Using linq2sql I am trying to select all TABLE1 entries such that their corresponding TABLE2 values contains at least 1 item in the list I pass it.
Here's some sample code I was using in...
I've been very happily using PredicateBuilder but until now have only used it for queries with only either concatenated AND statements or OR statements. Now for the first time I need a pair of OR statements nested along with a some AND statements like this:
select x from Table1 where a = 1 AND b = 2 AND (z = 1 OR y = 2)
Using the docu...
I have two tables. Report and ReportData.
ReportData has a constraint ReportID.
How can I write my linq query to return all Report objects where the predicate conditions are met for ReportData? Something like this in SQL:
SELECT * FROM Report as r
Where r.ServiceID = 3 and r.ReportID IN (Select ReportID FROM ReportData WHERE JobID LIKE...
I needed to build a dynamic filter and I wanted to keep using entities. Because of this reason I wanted to use the PredicateBuilder from albahari.
I created the following code:
var invoerDatums = PredicateBuilder.True<OnderzoeksVragen>();
var inner = PredicateBuilder.False<OnderzoeksVragen>();
foreach (var filter in set.RapportInvoerF...
I am working on a project that uses Albahari's PredicateBuilder library http://www.albahari.com/nutshell/ to create a linq expression dynamically at run time. I would like to find a way to translate this dynamically created linq predicate of type Expression<Func<T, bool>> into a readable english statement at runtime.
I'll give a stati...
We have a project using LINQ to SQL, for which I need to rewrite a couple of search pages to allow the client to select whether they wish to perform an and or an or search.
I though about redoing the LINQ queries using PredicateBuilder and have got this working pretty well I think. I effectively have a class containing my predicates, e....
I really like PredicateBuilder. It allows me to build all sorts of queries very dynamically. The predicate variable can be passed around to different objects and they can add onto it with values they know about, etc. Except when I am needing to use a .Contains on a hashed collection. Bzzt! Crash and burn.
For instance (example/pseudo co...
I'm trying to use the PredicateBuilder for adding a list of values to a query.
I want the return Dataset to include all records where the "pkey" value matches at least one of the strings in the list.
In order to simplify the sample code, I've added a list of sample strings directly to the Domain Servie, while this will be passed from t...
Here's the scenario:
Silverlight 4.0, DataGrid, PagedCollectionView itemssource.
The objective is to apply a Filter to the PCV. The filter needs to be a Predicate<object>(Method) - where Method implements some logic against the object and returns true/false for inclusion.
What I have is a need to optionally include 3 different criteria ...
I looked through PredicateBuilder sources and its' implementation makes me curious. Let's look at Or method implementation:
public static Expression<Func<T, bool>> Or<T> (this Expression<Func<T, bool>> expr1,
Expression<Func<T, bool>> expr2)
{
var invokedExpr = Expression.Invok...
Hi,
Quick question on how to get even more out of PredicateBuilder. It works as per below:
IQueryable<Product> SearchProducts (params string[] keywords)
{
var predicate = PredicateBuilder.False<Product>();
foreach (string keyword in keywords)
{
string temp = keyword;
predicate = predicate.Or (p => p.Description.Contains...
I have a situation where I have to dynamically build a linq query based on user selections.
If I had to dynamically generate sql I could do it this way:
var sb = new StringBuilder();
sb.AppendLine("SELECT * FROM products p");
sb.AppendLine("WHERE p.CategoryId > 5");
// these variables are not static but ...