Could you show me an example how to convert string when I am selecting using Linq to entity to proper case? Thank you
+1
A:
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
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);
astander
2010-04-25 16:15:10
In my case I'm binding datalist with linq to entity, thats why I need to convert when Im selecting
George
2010-04-25 16:22:41
I have some data like TABLE, WORD, APPLE and I need to convert them to Table, Word, Apple ...
George
2010-04-25 16:27:44
Then this should help you with that.
astander
2010-04-25 16:32:03