How can I rename table column renaming using LINQ like in regular SQL
SELECT t.template_nm as [Template Name]
FROM Template t
I found a answer from the internet, I can rename the column name. But can't have spaces be开发者_JS百科tween two words.
var template = from t in db.TEMPLATEs
select new { Template_Name = t.TEMPLATE_NM };
But I want to rename it without underscore(_) "Template Name"
Pls help
Thank You
Quite simply, you can't. You must give each column a valid c# variable name.
This is used to construct an anonymous class with your given property names. You will need to refer to these later on in code, and so it has to be valid c# code.
You can use DataAnnotations or just make the view detect Camel Notation and add spaces ;)
精彩评论