添加属性在LINQ2SQL DBML性能 [英] Adding attributes to properties in the Linq2Sql DBML

查看:116
本文介绍了添加属性在LINQ2SQL DBML性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在与我们的应用程序使用的所有数据库表和字段包含数据库的元数据。 从这个元数据,我们生成code,其中包含部分类,扩展我们的LINQ2SQL实体。

We are working with a database containing metadata on all database tables and fields used in our applications. From this metadata, we generate code that contains partial classes, extending our Linq2Sql entities.

我们必须增加一个过时的标志在我们的元数据,这应该又过时的属性添加到标志性的判定中的LINQ的对象的想法。 (使用老油田产生警告,在我们的code)

We had the idea of adding an "obsolete" flag in our metadata, which should in turn add the Obsolete-attribute to the flagged properies in the Linq object. (generating warnings in our code using old fields)

是这种类型的扩展可能在部分类?只需添加一个部分类文件的属性的属性?这听起来很像部分产权,这是我因子评分没有在.NET中存在。

Is this type of extension possible in a partial class? To just add an attribute to a property in a partial class file? This sounds a lot like a "partial property", something I tought didn't exist in .NET.

推荐答案

是的,检查出的<一个href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.metadatatypeattribute.metadatatypeattribute.aspx"相对=nofollow> MetadataType 属性。

很好的例子<一href="https://web.archive.org/web/20131231104625/http://goneale.com/2009/03/04/using-metadatatype-attribute-with-aspnet-mvc-xval-validation-framework/"相对=nofollow>此处。在这种情况下,他们要添加的属性进行验证的目的,但没有理由你不能做同样的指示过时。

Good example here. In this context, they want to add attributes for the purposes of validation, but no reason you couldn't do the same to indicate obsolescence.

这篇关于添加属性在LINQ2SQL DBML性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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