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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:06:19+00:00 2026-05-16T10:06:19+00:00

I am trying to convert the following SQL into Subsonic syntax using the SqlQuery

  • 0

I am trying to convert the following SQL into Subsonic syntax using the SqlQuery functionality:

SELECT DISTINCT * FROM FamilyMemberTeamRole FMTR 
INNER JOIN TeamRole TR ON FMTR.TeamRoleId = TR.TeamRoleId
INNER JOIN Team T ON T.TeamId = TR.TeamId
LEFT JOIN FamilyMemberClassHistory FMCH ON FMCH.FamilyMemberClassHistoryId = FMTR.FamilyMemberClassHistoryId
LEFT JOIN CBSClass CG ON CG.CBSClassGroupId = FMCH.CBSClassGroupId
LEFT JOIN CBSClassSession CS ON CG.CBSClassGroupId = CS.CBSClassGroupId 
AND (CS.ClassStartDate <= FMTR.EndDate or FMTR.EndDate IS NULL)
AND (CS.IsHistory = 0 OR CS.IsHistory = NULL)
WHERE FMTR.FamilyMemberId = @FamilyMemberId

I came up with this however something is wrong with my syntax on the last left join as I do not know how to compare values from within the SqlQuery to themselves.

SqlQuery sql = new Select().From(FamilyMemberTeamRole.Schema.TableName)
.InnerJoin(TeamRole.TeamRoleIdColumn, FamilyMemberTeamRole.TeamRoleIdColumn)
.InnerJoin(Team.TeamIdColumn, TeamRole.TeamIdColumn)
.LeftOuterJoin(FamilyMemberClassHistory.FamilyMemberClassHistoryIdColumn, FamilyMemberTeamRole.FamilyMemberClassHistoryIdColumn)
.LeftOuterJoin(CBSClass.CBSClassGroupIdColumn, FamilyMemberClassHistory.CBSClassGroupIdColumn)
.LeftOuterJoin(CBSClassSession.CBSClassGroupIdColumn, CBSClass.CBSClassGroupIdColumn)
.AndExpression(CBSClassSession.Columns.ClassStartDate).IsLessThanOrEqualTo(FamilyMemberTeamRole.Columns.EndDate)
.Or(FamilyMemberTeamRole.Columns.EndDate).IsNull().CloseExpression()
.AndExpression(CBSClassSession.Columns.IsHistory).IsEqualTo(false)
.Or(CBSClassSession.Columns.IsHistory).IsNull().CloseExpression()
.Where(FamilyMemberTeamRole.Columns.FamilyMemberId).IsEqualTo(this.FamilyMemberId)
.Distinct();
  • 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-16T10:06:19+00:00Added an answer on May 16, 2026 at 10:06 am

    You can always check what query subsonic generates for you with the BuildSqlStatement() method:

    SqlQuery query = DB.Select().From<Product>();
    String output = query.BuildSqlStatemtent();
    

    But I think I know what the problem is: SubSonic2 Join methods don’t support joining on multiple columns as far as I know: subsonic 2 join on multiple columns

    So you basically you have two options.

    a) do a “comma join”

    SELECT * FROM table1
    INNER JOIN table2 ON table1.id = table2.table1_id
    

    is the same as this query below but more readable

    SELECT * FROM table1, table2
    WHERE table1.id = table2.table1_id
    

    At least that’s true for mysql

    Edit: That won’t work with subsonic as I figured out in my question (but have forgetten)

    http://www.mysqlperformanceblog.com/2010/04/14/is-there-a-performance-difference-between-join-and-where/

    b) Use an InlineQuery which is subsonic’s backdoor to execute plain sql.

        private class Process
        {
            public Int64 Id { get; set; }
            public string User { get; set; }
            public string Host { get; set; }
            public string Db { get; set; }
            public string Command { get; set; }
            public string State { get; set; }
            public string Info { get; set; }
        }
    
        var result = DB.Query().ExecuteTypedList<Process>("SHOW FULL PROCESSLIST");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You will need to get a facebook account representative to… May 16, 2026 at 3:46 pm
  • Editorial Team
    Editorial Team added an answer This is due to String interning. Java (The JVM) keeps… May 16, 2026 at 3:46 pm
  • Editorial Team
    Editorial Team added an answer I would expect that you are persisting the configuration data… May 16, 2026 at 3:46 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I am trying to convert the following SQL into a LINQ expression SELECT COUNT(ID)
I have to perform the following SQL query: select answer_nbr, count(distinct user_nbr) from tpoll_answer
I am trying to convert the following stored proc to a LinqToSql call (this
I am trying to pass data from SQL, to C#, then to an R
I am trying to convert a standard std::string into an NSString but I'm not
I am trying to use the following code to convert a hash of options
I am trying to convert some of my stored procedures to Linq and am
I am trying to merge records from an Oracle database table to my local
I am trying to convert a date with individual parts such as 12, 1,
I'm trying to grab thousands of invoices (and other stuff) from a text file

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.