ASP.NET MVC / Linq-to-SQL classes: Can I get it to infer readable display names?

Posted by Gary McGill on Stack Overflow See other posts from Stack Overflow or by Gary McGill
Published on 2010-03-29T13:29:11Z Indexed on 2010/03/29 13:33 UTC
Read the original article Hit count: 221

Filed under:
|

If I have a table Orders with fields CustomerID, OrderID and OrderDate, then the "Linq-to-SQL classes" generated class will be called Orders, with members called CustomerID, OrderID and OrderDate. So far so good.

However, if I then do Html.LabelFor(m => m.OrderDate) then the generated text will be "OrderDate" instead of "Order Date".

I tried using Order_Date as the field name, but that didn't work. Is there any way to get it to infer a better display name?

[I know that I can use data annotations to specify the display name explicitly, but I really don't want to do that for all my classes/members - I just want it to work by convention.]

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about linq-to-sql