2

到目前为止,我可以创建Custom Membership Providerand 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在我的数据库中使用我的表,我应该怎么做?我需要读取数据的方式。

谢谢你的帮助。

4

1 回答 1

0

可能对原始海报没有多大用处,但看起来您可以按照此博客文章中的说明进行操作。要点是您让生成的配置文件类继承您自己的类,该类又继承自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>
于 2020-01-30T08:05:00.947 回答