如何为名称中包含空格的列创建复杂数据类型 [英] How to create complex datatype for column with spaces in the name

查看:101
本文介绍了如何为名称中包含空格的列创建复杂数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从存储过程中获取结果集。并且归档名称包含空格

ex:名字第二名

但EF重命名字段。我怎样才能保持相同的字段名称?

解决方案

我很确定你不能。如果您正在讨论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.


这篇关于如何为名称中包含空格的列创建复杂数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆