SqlExpression Creating Upper SQL Query
I have the following code:
SqlExpression<Postcodes> sqlExpression = db.From<Postcodes>()
.Where(x => x.CityId.StartsWith(searchString))
.OrderBy(x => x.CityId)
.ThenBy(x => x.ZipCode)
.Take(take);
When I look in debug, I can see that sqlExpression.BodyExpression
has:
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
Why does it generate "upper" even though I didn't use x.CityId.ToUpper()
?
Update:
When I use "nort"
as the input, I can see this in the debug output:
2018-11-23 07:37:22,781 [21] DEBUG ServiceStack.OrmLite.OrmLiteReadCommandExtensions [(null)] - SQL: SELECT TOP 100 "ZipCode", "CityId", "StateId"
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
ORDER BY "CityId", "ZipCode"
PARAMS: @0=NORT%
Looks like by default it's using case insensitive matching.
Why is the default case insensitive and how could I force it to do a case sensitive match?
Update:
As Gabitu pointed out, it just makes the column name upper case and doesn't affect the query. What is the point in making the column name upper case?
c# ormlite-servicestack
add a comment |
I have the following code:
SqlExpression<Postcodes> sqlExpression = db.From<Postcodes>()
.Where(x => x.CityId.StartsWith(searchString))
.OrderBy(x => x.CityId)
.ThenBy(x => x.ZipCode)
.Take(take);
When I look in debug, I can see that sqlExpression.BodyExpression
has:
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
Why does it generate "upper" even though I didn't use x.CityId.ToUpper()
?
Update:
When I use "nort"
as the input, I can see this in the debug output:
2018-11-23 07:37:22,781 [21] DEBUG ServiceStack.OrmLite.OrmLiteReadCommandExtensions [(null)] - SQL: SELECT TOP 100 "ZipCode", "CityId", "StateId"
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
ORDER BY "CityId", "ZipCode"
PARAMS: @0=NORT%
Looks like by default it's using case insensitive matching.
Why is the default case insensitive and how could I force it to do a case sensitive match?
Update:
As Gabitu pointed out, it just makes the column name upper case and doesn't affect the query. What is the point in making the column name upper case?
c# ormlite-servicestack
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32
add a comment |
I have the following code:
SqlExpression<Postcodes> sqlExpression = db.From<Postcodes>()
.Where(x => x.CityId.StartsWith(searchString))
.OrderBy(x => x.CityId)
.ThenBy(x => x.ZipCode)
.Take(take);
When I look in debug, I can see that sqlExpression.BodyExpression
has:
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
Why does it generate "upper" even though I didn't use x.CityId.ToUpper()
?
Update:
When I use "nort"
as the input, I can see this in the debug output:
2018-11-23 07:37:22,781 [21] DEBUG ServiceStack.OrmLite.OrmLiteReadCommandExtensions [(null)] - SQL: SELECT TOP 100 "ZipCode", "CityId", "StateId"
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
ORDER BY "CityId", "ZipCode"
PARAMS: @0=NORT%
Looks like by default it's using case insensitive matching.
Why is the default case insensitive and how could I force it to do a case sensitive match?
Update:
As Gabitu pointed out, it just makes the column name upper case and doesn't affect the query. What is the point in making the column name upper case?
c# ormlite-servicestack
I have the following code:
SqlExpression<Postcodes> sqlExpression = db.From<Postcodes>()
.Where(x => x.CityId.StartsWith(searchString))
.OrderBy(x => x.CityId)
.ThenBy(x => x.ZipCode)
.Take(take);
When I look in debug, I can see that sqlExpression.BodyExpression
has:
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
Why does it generate "upper" even though I didn't use x.CityId.ToUpper()
?
Update:
When I use "nort"
as the input, I can see this in the debug output:
2018-11-23 07:37:22,781 [21] DEBUG ServiceStack.OrmLite.OrmLiteReadCommandExtensions [(null)] - SQL: SELECT TOP 100 "ZipCode", "CityId", "StateId"
FROM "search"."Postcodes"
WHERE upper("CityId") like @0
ORDER BY "CityId", "ZipCode"
PARAMS: @0=NORT%
Looks like by default it's using case insensitive matching.
Why is the default case insensitive and how could I force it to do a case sensitive match?
Update:
As Gabitu pointed out, it just makes the column name upper case and doesn't affect the query. What is the point in making the column name upper case?
c# ormlite-servicestack
c# ormlite-servicestack
edited Nov 23 at 11:48
asked Nov 23 at 7:29
Backwards_Dave
2,64873264
2,64873264
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32
add a comment |
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32
add a comment |
1 Answer
1
active
oldest
votes
I think it is doing Upper to your column name, so it wouldn't affect your query at all.
The query will be something like the following:
SELECT *
FROM "search"."Postcodes"
WHERE CITYID like @0
ORDER BY "CityId"
Probably is making it uppercase because your column is case insensitive. Check whether your column is sensitive or insensitive with the following command:
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Postcodes' AND
CHARACTER_SET_NAME IS NOT NULL AND
TABLE_SCHEMA = 'search'
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442332%2fsqlexpression-creating-upper-sql-query%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think it is doing Upper to your column name, so it wouldn't affect your query at all.
The query will be something like the following:
SELECT *
FROM "search"."Postcodes"
WHERE CITYID like @0
ORDER BY "CityId"
Probably is making it uppercase because your column is case insensitive. Check whether your column is sensitive or insensitive with the following command:
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Postcodes' AND
CHARACTER_SET_NAME IS NOT NULL AND
TABLE_SCHEMA = 'search'
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
add a comment |
I think it is doing Upper to your column name, so it wouldn't affect your query at all.
The query will be something like the following:
SELECT *
FROM "search"."Postcodes"
WHERE CITYID like @0
ORDER BY "CityId"
Probably is making it uppercase because your column is case insensitive. Check whether your column is sensitive or insensitive with the following command:
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Postcodes' AND
CHARACTER_SET_NAME IS NOT NULL AND
TABLE_SCHEMA = 'search'
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
add a comment |
I think it is doing Upper to your column name, so it wouldn't affect your query at all.
The query will be something like the following:
SELECT *
FROM "search"."Postcodes"
WHERE CITYID like @0
ORDER BY "CityId"
Probably is making it uppercase because your column is case insensitive. Check whether your column is sensitive or insensitive with the following command:
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Postcodes' AND
CHARACTER_SET_NAME IS NOT NULL AND
TABLE_SCHEMA = 'search'
I think it is doing Upper to your column name, so it wouldn't affect your query at all.
The query will be something like the following:
SELECT *
FROM "search"."Postcodes"
WHERE CITYID like @0
ORDER BY "CityId"
Probably is making it uppercase because your column is case insensitive. Check whether your column is sensitive or insensitive with the following command:
SELECT COLUMN_NAME, COLLATION_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE
TABLE_NAME = 'Postcodes' AND
CHARACTER_SET_NAME IS NOT NULL AND
TABLE_SCHEMA = 'search'
edited Nov 23 at 13:52
answered Nov 23 at 10:09
Gabitu
1414
1414
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
add a comment |
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Good point! But what is the point of having the column name upper case?
– Backwards_Dave
Nov 23 at 11:24
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
Please, have a look on this webucator.com/how-to/how-check-case-sensitivity-sql-server.cfm Check if your column is case insensitive with this: SELECT COLUMN_NAME, COLLATION_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Postcodes' AND CHARACTER_SET_NAME IS NOT NULL AND TABLE_SCHEMA = 'search'
– Gabitu
Nov 23 at 13:50
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
It says "SQL_Latin1_General_CP1_CI_AS"
– Backwards_Dave
Nov 26 at 4:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53442332%2fsqlexpression-creating-upper-sql-query%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
i'd be suggesting it's trying to be case-insensitive
– JohnB
Nov 23 at 7:32