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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:01:46+00:00 2026-05-21T22:01:46+00:00

I have a query where I am only interested in the row count, however

  • 0

I have a query where I am only interested in the row count, however the query that NHibernate produces does not work with Sybase. I already have a custom Sybase dialect, but I can’t find where to override the rowcount.

Given the following code:

var a = from b in table where b.something = 5 select b
var rows = a.Count

Generates an SQL similar to this:

select cast(count(*) as INTEGER) as p1 from table

I don’t get why NHibernate wants to cast the count result, nor how I can override the dialect or elsewhere so NHibernate doesn’t include the cast. The result of a count is castable to integer anyways.

If I however use QueryOver, things work perfectly. The problem then however, is that one off my conditions is dependent on the length of a string (yes, the db design could be better, but I can currently not change it). Using linq to call .Length on a string in the conditions work. However I can’t use the string length as a condition in the QueryOver expressions. I also need a contains operation, which works with linq, but not QueryOver.

Is there a way to override how the Count query is generated, so it will work?
I am only interested if there is any rows matching, not the count, is there a different way of doing that?
Can instead the QueryOver? interface to use the SQL length and in operators?

  • 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-21T22:01:47+00:00Added an answer on May 21, 2026 at 10:01 pm

    You can understand if there are any rows matching by using Any function like this:

    var a = from b in table where b.something = 5 select b; 
    var isMatch = a.Any();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data analysis that needs to perform. On average, it would involve
Say I have a table which I query like so: select date, value from
I'd like a query that at its simplest will join 2 tables together with
I am interested to find out what is the best/fastest (most efficient) way to
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have a tricky situation in trying to get information from multiple queries into
I have two tables, one called customer and one called customer_attributes . The idea
I'm interested in exposing a direct REST interface to collections of JSON documents (think
Problem: a table of coordinate lat/lngs. Two rows can potentially have the same coordinate.
I'm using OleDb to select data from excel spreadsheets. Each spreadsheet can contain many

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.