predicate

How can I pass additional parameters to predicate?

My issue is to Find exact one Calendar object from a List Of(Calendar) by passing a particular date. I got to know about the predicate but not sure about passing parameter to it. colorcode is List Of (Calendar) and calendar class has a property called DtmDate with which I want to compare and return the desired object. Dim a As Calenda...

Evaluate outer xpath-expression in xpath-predicate

Hi, i have a problem with a xpath-statement. Basically, the problem can be explained at the following code: <xsl:for-each select="/b1im:B1IMessage/b1im:Header/b1im:Z/SortInbound/group"> <!-- Check if entry from duplicate table is found for the current AccountingEntry --> <xsl:variable name="exter...

Expression<Func<T,bool>> - How to Handle Ambiguous Method Signatures?

Hi Guys, I have an interface contract that looks like this: ICollection<FooBar> FindByPredicate(Expression<Func<FooBar,bool>> predicate); ICollection<Foo> FindByPredicate(Expression<Func<Foo,bool>> predicate); ICollection<Bar> FindByPredicate(Expression<Func<Bar,bool>> predicate); Foo and Bar are concrete classes which inherit from t...

weighted RDF predicate (owl:ObjectProperty)

in RDF a statement is represented with S,P and O; In OWL the owl:ObjectProperty represents the predicate logic. (S) (P) (O) I like dog <owl:Class rdf:about="Person" /> <owl:NamedIndividual rdf:about="I"> <rdf:type rdf:resource="Person"/> <like rdf:resource="Dog"/> </owl:NamedIndividual> <owl:Class rdf:about="Pet" /> <ow...

Speeding up search using predicate

Hi everybody! I have an array with about 6000 entries, everyone with a date, in the form of 4 integers (year, month, day, hour). I want to find all the entries with a given day, and i'm doing like this: NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar]; unsigned unitFl...

Need help trying to EagerLoad some data in EntityFramework.

Hi folks, I'm trying to do some eager loading on an EF Entity. so, if the entity is called Orders .. then I guess i would do the following... _someContext.Orders.Include("Whatever") .... But the problem is, I have a method like the following ... public IQueryable<Order> Find(Expression<Func<Order, bool>> predicate) { return Curr...

Declaring func<in T,Out Result> dynamically

Consider this: var propertyinfo = typeof(Customer).GetProperty(sortExpressionStr); Type orderType = propertyinfo.PropertyType; now i want to declare Func<int,orderType> i know its not possible directly since ordertype is at runtime but is there is any workarround ? this is exactly what i want to do : var propertyinfo = t...

Fetch Specific Number of Random Rows from CoreData

I'm using the code below to Fetch a queried set of all rows using CoreData matching the search criteria: itemType = 1. But what I need to do is to Fetch a specific number of Random rows from the data instead. For example, instead of retrieving all 100 rows of data in which the column name dataType = 1, I need to get 25 rows randomly in w...

Fetch only the UniqueID column and populate array

I'm using the code below to populate an array from my ManagedObjectContext, but what I would like to do is to fetch only the unique ID numbers of each row matching my query (itemType = 1) and populate the fetchResults array with only these unique ID numbers. Is that possible? Any help is appreciated. lq NSFetchRequest *request = [[NSFe...

Expression.Call - Calling linq extension: FirstOrDefault, Where....

I am trying to create the following dynamically, however I am having problems calling the extension method "FirstOrDefault" using(var context = new Entities()) { var list = context.Engines.Include("Cars").Select(e => e.Cars.FirstOrDefault()).ToList(); } I have the following Expression parameter = Expression.P...

Using compound XPath Predicates to search XML message

I'm having trouble figuring out how to select data using a compound XPath query so that I can essentially find the 5th column of row in my data. Here is my example XML: <sample> <OBX> <field position="1">1</field> <field position="2">My Value</field> </OBX> <OBX> <field position="1">2</field> <field position="2">My other...

Dynamically creating an Expression calling method EntityFunctions.DiffDays

I am trying to create the following Where clause expression dynamically: context.Cars. Where(c => EntityFunctions.DiffDays(c.Created, c.Created) == null). ToList() This is the code I am using to create the expression: var parameter = Expression.Parameter(typeof(Car), "c"); var property = Expression.Property(parameter, "Created"); var...

How to chain method overloads that accept Func<> delegates ? (C#)

I have a method with two overloads, as follows: bool Evaluate(Func<bool> condition) { // Some logic return condition.Invoke(); } bool Evaluate<T>(Func<T, bool> condition, T value) { // Same logic as the first method overload return condition.Invoke(value); } Since both method overloads contain largely identical logi...

Dynamic LINQ help for sorting problem

I have a simple IEnumerable collection of Order objects. I want to write a generic sort function that accepts the collection and a sortkey that corresponds to a property on an Order object. I don't want to hardcode the sort instructions for every property. How can I build a dynamic LINQ string that automatically generates the LINQ for me...

EntityFramework Casting issues

I am building my query using PredicateBuilder from LinqKit. it is great and does exactly what i am looking for. To make my code more reusable (tables and views) i created a generic predicate builder class: public class LocalPredicateBuilder<T> where T : IResort ... var predicate = PredicateBuilder.True<T>( which exposes BuildPre...