且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何为名称中包含空格的列创建复杂数据类型

更新时间:2022-11-02 23:40:49

我很确定你不能。如果您正在讨论EF创建具有映射到字段名称的属性的对象的方式,例如:



 MyTable.First_Name 





您不能拥有包含空格的属性名称。这是语言的设计方式,空格标记标识符或语言元素的结尾。你不能在元素中有空格,所以它必须使它成为一个长名。



我知道有人会因为这样说而跳过我,但在每个数据库中我已经完成了,我将竭尽全力:



1.避免使用表格和列名称中的空格。这也搞砸了SQL语句。

2.避免使用常用关键字(例如列名日期)



以后这会有很多帮助


I am getting result set from Stored procedure. And filed name contains blank spaces
ex : "First Name" "Second Name"
But EF renames fields. how can i maintain same field name?

I'm pretty sure you can't. If you are talking about the way that EF creates an object with properties that map to field names, like:

MyTable.First_Name



You can't have a property name with a space in it. This is the way that the language is designed, whitespace marks the end of an identifier or language element. You can't have whitespace inside elements, so it has to make it one long name.

I know somebody will jump on me for saying this, but in every database I've done, I go through great lengths to:

1. Avoid spaces in table and column names. This also messes up SQL statements.
2. Avoid common keywords (column name Date, for example)

This helps out a lot later.