Is there any query in Entity Framework so i can convert first letter of each record in uppercase
ex:
India
China
Australia
England
Japan
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Sep 24, 2012, 6:42 AM
TextInfo ti = CultureInfo.GetCultureInfo("en-Us").TextInfo;
var query1 = from bookinformation in ent.BOOKINFORMATIONs.AsEnumerable() select ti.ToTitleCase(bookinformation.AUTHORNAME.ToLower());
query1 = query1.Distinct();
cmb1.DataSource = query1;
cmb1.DataBind();
nallyaPosted Sep 24, 2012, 7:49 AM
it works great.
nallyaPosted Sep 24, 2012, 3:34 AM
LINQ to Entities does not recognize the method 'System.String ToTitleCase(System.String)' method, and this method cannot be translated into a store expression.
And my query is
TextInfo ti = CultureInfo.GetCultureInfo("en-Us").TextInfo;
var query1 = from bookinformation in ent.BOOKINFORMATIONs select ti.ToTitleCase(bookinformation.AUTHORNAME.ToLower());
query1 = query1.Distinct();
cmb1.DataSource = query1;
cmb1.DataBind();
VulpesPosted Sep 21, 2012, 6:36 AM
using System.Globalization;
//....
TextInfo ti = CultureInfo.GetCultureInfo("en-Us").TextInfo; // say
var query1 = from bookinformation in ent.BOOKINFORMATIONs select ti.ToTitleCase(bookinformation.COUNTRY.ToLower());