Linq to Entity convert string to proper case
Could you show me an example how to convert string when I am selecting using Linq to entity to pro开发者_JAVA技巧per case? Thank you
I dont think you need purely LINQ for this.
Have a look at this example
string sampleString = "this is a title";
CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo currentInfo = currentCulture.TextInfo;
sampleString = currentInfo.ToTitleCase(sampleString);
//output:
//This Is A Title
TextInfo.ToTitleCase Method
So in a LINQ select you could use something like
CultureInfo currentCulture = System.Threading.Thread.CurrentThread.CurrentCulture;
TextInfo currentInfo = currentCulture.TextInfo;
List<string> testList = new List<string> { "foo", "bAr", "fOO bar Test tAdA" };
var correct = from s in testList
select currentInfo.ToTitleCase(s);
精彩评论