SqlExpression Creating Upper SQL Query












0














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?










share|improve this question
























  • i'd be suggesting it's trying to be case-insensitive
    – JohnB
    Nov 23 at 7:32
















0














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?










share|improve this question
























  • i'd be suggesting it's trying to be case-insensitive
    – JohnB
    Nov 23 at 7:32














0












0








0







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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












1 Answer
1






active

oldest

votes


















1














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'





share|improve this answer























  • 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











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
});


}
});














draft saved

draft discarded


















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









1














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'





share|improve this answer























  • 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
















1














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'





share|improve this answer























  • 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














1












1








1






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'





share|improve this answer














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'






share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)