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 8044567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T05:16:16+00:00 2026-06-05T05:16:16+00:00

I have a class called Query with a field called CreatedBy, the username who

  • 0

I have a class called Query with a field called CreatedBy, the username who created it.
I also have a class called Permissions with the permissions for the query.

I created a query that returns me based on the current user, the queries the user has access to, based on the Permissions collection, but I need to JOIN that with the queries that the user also created.

If for some reason, the user who created it, its also in the Permissions collection, it shouldnt be returned twice.

Here is my code

public class Query
    {
        public int QueryId { get; set; }
        public string QueryName { get; set; }
        public string QuerySql { get; set; }
        public string CreatedBy { get; set; }
        public string QueryType { get; set; }
        public string RequestType { get; set; }
        public string Column1 { get; set; }
        public string Operator1 { get; set; }
        public string Value1 { get; set; }
        public string Connector2 { get; set; }
        public string Column2 { get; set; }
        public string Operator2 { get; set; }
        public string Value2 { get; set; }
        public string Connector3 { get; set; }
        public string Column3 { get; set; }
        public string Operator3 { get; set; }
        public string Value3 { get; set; }
        public virtual ICollection<Permission>  Permissions { get; set; }
    }


  public class Permission
    {
        public int PermissionId { get; set; }
        public string UserName { get; set; }
    }

   public IQueryable<Query> GetQueriesForUser(string userName)
        {
            return _context.Queries.Where(q => q.Permissions.Any(p => p.UserName.Equals(userName)));
        }
  • 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-06-05T05:16:17+00:00Added an answer on June 5, 2026 at 5:16 am

    Are you sure you need a join? It looks like you need UNION ALL:

    _context.Queries.Where(q => q.Permissions.Any(p => p.UserName == userName)).Concat(
        _context.Queries.Where(q => q.CreatedBy == userName));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class called Question that has a property called Type. Based on
Suppose that I have a JPA-annotated class called MyData with a primary identifier field
I have a class called UserInfo that contains details about a given user. There
I have a class called Sprite, and ballSprite is an instance of that class.
this is my escenary, I Have a class called Plantilla that contains severals propertyes
I have a domain object, Expense, that has a field called initialFields . It's
If I have a model called Product class Product include Mongoid::Document field :product_id field
I have a class called Stream that has many records in the database, and
I have a collection with a string field called named in my Mongoid based
I have a PHP class called Vehicle that manages everything pertaining to cars,motorbikes and

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.