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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:20:05+00:00 2026-05-28T18:20:05+00:00

I have the following Subsonic 3.0 query, which contains a nested NotIn query: public

  • 0

I have the following Subsonic 3.0 query, which contains a nested NotIn query:

public List<Order> GetRandomOrdersForNoReason(int shopId, int typeId)
{
    // build query    
    var q = new SubSonic.Query.Select().Top("1")
        .From("Order")
        .Where("ShopId")
        .IsEqualTo(shopId)
        .And(OrderTable.CustomerId).NotIn(
            new Subsonic.Query.Select("CustomerId")
                .From("Customer")
                .Where("TypeId")
                .IsNotEqualTo(typeId))
            .OrderDesc("NewId()");

    // Output query
    Debug.WriteLine(q.ToString());   

    // returned typed list
    return q.ExecuteTypedList<Order>();
}

The internal query appears to be incorrect:

SELECT TOP 1 *
 FROM [Order]
 WHERE ShopId = @0 AND CustomerId NOT IN (SELECT CustomerId
 FROM [Customer]
 WHERE TypeId = @0)
 ORDER BY NewId() ASC

You’ll notice that both parameters are @0. I’m assuming that the parameters are enumerated (starting at zero), for each “new” Select query. However, in this case where the two Select queries are nested, I would have expected the output to have two parameters named @0 and @1.

My query is based on one that Rob Conery gave on his blog as a preview of the “Pakala” query tool that became Subsonic 3. His example was:

int records = new Select(Northwind.Product.Schema)
    .Where("productid")
    .In(
        new Select("productid").From(Northwind.Product.Schema)
        .Where("categoryid").IsEqualTo(5)
        )
    .GetRecordCount();

Has anyone else seen this behavior? Is it a bug, or is this an error or my part? Since I’m new to Subsonic I’m guessing that this probably programmer error on my part but I’d like confirmation if possible.

  • 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-28T18:20:07+00:00Added an answer on May 28, 2026 at 6:20 pm

    Just came across this exact same issue in the latest release, so apparently it hasn’t been fixed yet. I tried switching the order of the conditions (putting the NotIn condition first) and that did the trick. Here’s what the new code looks like, which produced parameters @0 and @1 instead of @0 and @0:

    var q = new SubSonic.Query.Select().Top("1")
        .From("Order")
        .Where(OrderTable.CustomerId).NotIn(
            new Subsonic.Query.Select("CustomerId")
                .From("Customer")
                .Where("TypeId")
                .IsNotEqualTo(typeId)
        )
        .And("ShopId")
        .IsEqualTo(shopId)
        .OrderDesc("NewId()");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following date as string 091020. I am using SubSonic as my
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have following Code Block Which I tried to optimize in the Optimized section
I have following classes. class A { public: void fun(); } class B: public
I want to execute the following query using Subsonic: SELECT MAX([restore_date]) FROM [msdb].[dbo].[restorehistory] While
Assuming I have the following schema table A: ID int primary key value varchar(255)
I have following code that creates Linq query. I've never used Linq until today
I have the following code using SubSonic 2.1/2.2 SubSonic.Update(<some table>) .Set(<column A>) .EqualTo(<column B>).
Have following code: public interface ITest { string St1 { get; } } public
I have following scenario: alt text http://static.zooomr.com/images/7579022_e64808b855_o.png We have a WebService which poses as

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.