开发者

linq to sql - renaming column name

开发者 https://www.devze.com 2023-03-03 07:10 出处:网络
How can I rename table column renaming using LINQ like in regular SQL SELECT t.template_nm as [Template Name]

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号