开发者

LINQ to SQL Problem with table named 'System'

I have the unfortunate problem that a database I'm trying to use with LINQ to SQL has a table 开发者_JS百科in it named 'System'. The side-effect of this is that there are HUGE namespace conflicts once the .dbml has been generated.

Renaming the table is not an option.

Any ideas you might have would be greatly appreciated!


Add a _ before or after the name in the dbml file


I think the best option would be renaming the table in the Designer/mapping, even though you can't rename it in the DB.


I generally construct my own Linq to Sql classes instead of using the .dbml files. A naming convention I use is TableName + "Dto". Dto standing for Data Transfer Object. If rolling your own Dto classes is not an option, you can simply go into the designer edit the name of your System table dbml to SystemDto. It will still map correctly to the database object, and yet you will have no name conflicts. If you're interested in seeing some hand rolled dto's let me know :). Hope this helps!


you have to disable the "Pluralize New Objects" feature.

Have a look at:

http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx

An easier and better way is just add a Namespace to the context. Right click on the Linq to SQL designer --> property --> ContextNameSpace

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜