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

  • Home
  • SEARCH
  • 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 6086045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:42:26+00:00 2026-05-23T11:42:26+00:00

I have two rateable objects E and S , S is contained within E

  • 0

I have two rateable objects E and S, S is contained within E so you say E.S and they both use the same object R to be rated; R will always have ONLY ONE rated object at a time so if R.E.HasValue == true then R.S.HasValue will never be true.

I have all the R objects from the database and I have E. What would be the lambda expression to get all Rs Where R.S in E.S??


UPDATE
I found this MSDN Documentation where it says:

Referencing a non-scalar variables,
such as an entity, in a query is not
supported. When such a query executes,
a NotSupportedException exception is
thrown with a message that states
“Unable to create a constant value of
type EntityType. Only primitive types
(‘such as Int32, String, and Guid’)
are supported in this context.”

So… I can’t use A-Dubb’s answer since the query reads

R.Where(r => r.SID.HasValue).Where(r => E.S.Contains(r.S))

Which results in a NotSupportedException… I still have the property R.SID which is of type int? but how could I then query all E.S to get their IDs?

P.S. E.S. is of type EntityCollection.

  • 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-23T11:42:27+00:00Added an answer on May 23, 2026 at 11:42 am

    I will say that IN clauses are normally represented with call to Contains. For example

    public class R {
       public int Id {get; set;}
    }
    
    public IEnumerable<R> InClause(IEnumerable<int> ids) {
       var subset = ids.ToList();
    
       return dbContext.Query<R>.Where(r => subset.Contains(r.Id));
    }
    

    I know that’s not the exact API call in EF, but it should help set the basis for your solution. Maybe you already know how to generate IN clauses but I figure if you did then you presumably wouldn’t be stuck. If the IN clause isn’t the difficult part of the query then what is? Maybe the piece of business logic you mentioned? Again, a C# object model would help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two insert statements, almost exactly the same, which run in two different
Have two fields start and end, both are dates, I want to write a
I have two types CREATE OR REPLACE TYPE my_record_type IS OBJECT ( name varchar2(30)
I have two queries serving the same purpose. SELECT * FROM #user INNER JOIN
I have two different types of dicom(medical imaging files) in the same folder. I
I have two applications written in Java that communicate with each other using XML
I have two arrays of animals (for example). $array = array( array( 'id' =>
I have two elements: <input a> <input b onclick=...> When b is clicked, I
I have two identical tables and need to copy rows from table to another.

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.