且构网

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

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

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

我找到了这个答案。



继续创建复杂的类型,替换列名称中的空格的下划线,或按照您喜欢命名复杂类型中的字段的任何惯例。



然后,在模型浏览器中单击您的功能导入。在Visual Studio 2010窗口的底部,应该有一个选项卡,其中显示映射详细信息。在这里,您可以指定与复合类型中每个字段对应的列的名称。用这里的空格键入列名称。


I have a stored procedure that returns columns with spaces and dashes in the column names. I cannot simply use the "Get Column Information" button to automatically generate a complex type for this stored procedure.

How do I handle the spaces and dashes in the field names since they are not legal characters for field names in C#?

I found the answer to this.

Go ahead and create the complex type substituting underscores for spaces in the column names or follow whatever convention you like naming the fields in the complex type.

Then, click on your function import in the Model Browser. At the bottom of the Visual Studio 2010 window, there should be a tab that says "Mapping Details". Here, you can specify the name of the column that corresponds to each field in your complex type. Type in the column names with the spaces here.