Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3332766
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:43:22+00:00 2026-05-17T23:43:22+00:00

I have a small custom object defined as: public class TimeSeriesDefinition { public int

  • 0

I have a small custom object defined as:

public class TimeSeriesDefinition
{  
    public int classID;
    public DateTime startTime;
    public DateTime endTime;
}

I’m passing a List classIDs, a List startTimes, and a List endTimes into an RIA Domain Service function. As a matter of organization, I was grouping these values into a List of TimeSeriesDefinitions and then trying to use a foreach loop to create an expression that would select with AND operators between the values in a class and OR operators between each class or implement a “.Any” query as suggested by the first answer I received below. The problem is that I can’t use the TimeSeriesDefinition class in a DomainService function because it is not a primitive type or one of my entity types (maybe I should just make an entity with this type?), so I need another method of achieving the desired query results. My original idea for using expressions that I never got anywhere with is here:

        Expression<Func<EventLog, bool>> bounds;
        Boolean assignedBounds = false;
        foreach (TimeSeriesDefinition ts in reporters)
        {
            if (assignedBounds.Equals(false))
            { 
                bounds = c => c.reporterID == ts.classID && c.reportDateTime >= ts.startTime && c.reportDateTime <= ts.endTime; 
                assignedBounds = true;
            }
            else
            { 
                Expression<Func<EventLog, bool>> newBounds = c => c.reporterID == ts.classID && c.reportDateTime >= ts.startTime && c.reportDateTime <= ts.endTime;
                bounds = Expression.Or(Expression.Invoke(bounds), Expression.Invoke(newBounds);
                // bounds = Expression<Func<EventLog, bool>>.Or(bounds, newBounds);
            }
        }

        return this.ObjectContext.EventLog.Where(bounds);

My goal is for the resultset to have all records of a ts.classID between ts.startDate and ts.EndDate. From what I’ve found online, it seems that making sure the parameters are correctly assigned is tricky as well, but right now I’m still getting a

“Cannot implicitly convert type ‘System.Linq.Expressions.BinaryExpression’ to ‘System.Linq.Expressions.Expression>'”

error at the line

 bounds = Expression.Or(Expression.Invoke(bounds), Expression.Invoke(newBounds);

Can anybody point me in the right direction? I suppose I could possibly build this whole thing into a query string somehow, but I’d rather not go there.

Thanks in advance for your insight!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:43:22+00:00Added an answer on May 17, 2026 at 11:43 pm

    If you Funcletize (localize) your references to TimeSeriesDefinition on the client side, you should be able to include them in your query (see Evaluator.PartialEval method in here http://msdn.microsoft.com/en-us/library/bb546158.aspx). You should be able to simply call it on your Expression object and have the references to TimeSeriesDefinitions lifted away to primitive constants:

    Evaluator.PartialEval(lambdaExpression);
    

    As for your compilation problem:

    bounds = Expression.Or(Expression.Invoke(bounds), Expression.Invoke(newBounds);
    

    The left hand side of that assignment is a generic LambdaExpression. The right hande side is a BinaryExpression. To do the assignment, you need to Lambda the Or and also provide a ParameterExpression for your InvocationExpressions:

    var parameterExpression = Expression.Parameter(typeof(EventLog));
    bounds = Expression.Lambda<Func<EventLog, bool>>(  
        Expression.Or(  
             Expression.Invoke(bounds, parameterExpression),  
             Expression.Invoke(newBounds, parameterExpression), 
        parameterExpression);
    

    However…you will probably run into the wonderful fact that RIA doesn’t support InvocationExpressions… (I haven’t verified this but I know EF doesn’t). You’ve got to Expand your InvocationExpressions to inline them (sort of like with the Funcletlizer mentioned above).

    LINQKit ( http://www.albahari.com/nutshell/linqkit.aspx ) provides one out of the box. It also provides helper methods for combining criteria as you mention above. If you don’t want the whole dependency on LINQKit, you can grab the source for the same thing here: http://www.java2s.com/Open-Source/CSharp/Content-Management-Systems-CMS/Kooboo/Microsoft/Data/Extensions/DataExtensions.cs.htm

    Then just change your Where to:

    return this.ObjectContext.EventLog.Where(InvocationExpander.Expand(bounds));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.