到目前为止,我可以创建Custom Membership Provider
和Custom Role Provider
,但我对Custom Profile Provider
有疑问。在查看了一些演示之后,我发现他们使用web.config
来定义配置文件的架构。例如,在代码<profile>
:
<properties>
<add name="AddressName"/>
<add name="AddressStreet"/>
<add name="AddressCity"/>
<add name="AddressState"/>
<add name="AddressZipCode"/>
<add name="AddressCountry"/>
</properties>
要访问该字段,他们会使用Profile.AddressName
,Profile.AddressStreet
等...
我的问题是:这是定义配置文件架构的唯一方法吗?如果我想在我的数据库中使用我的UserProfile
表,我该怎么办?我需要阅读的方式来写数据。
感谢您的帮助。
答案 0 :(得分:0)
原始海报可能没有太多用处,但看起来您可以像described in this blog post那样使用。要点是,让生成的概要文件类继承您自己的类,该类又从ProfileBase
继承,最后覆盖ProfileProvider
:
<profile inherits="Acme.MyApplication.ProfileCommon,MyApplication" defaultProvider="EfTableProfileProvider">
<providers>
<clear />
<add name="EfTableProfileProvider" type="Acme.MyApplication.EfTableProfileProvider,Facade" connectionStringName="ApplicationServices" applicationName="/MyApplication"/>
</providers>
</profile>