我試圖找出如何使用ProfileProvider
這是在這個例子中:http://www.codeproject.com/KB/aspnet/AspNetEFProviders.aspx實體框架配置文件提供程序示例..如何初始化和設置請幫助!
我已經得到了會員資格和角色提供偉大的工作,我就擁有了一切設置它究竟是如何在例子。
下面是我正在使用的類,就像成員資格和角色類。這將反過來被我的AccountController調用。
public class AccountProfileService : IProfileService
{
private readonly EFProfileProvider _provider;
public AccountProfileService() : this(null) {}
public AccountProfileService(ProfileProvider provider)
{
_provider = (EFProfileProvider)(provider ?? [What do I put here?!]);
}
public void SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection properties)
{
if (context == null) throw new ArgumentException("Value cannot be null or empty.", "context");
if (properties == null) throw new ArgumentException("Value cannot be null or empty.", "properties");
_provider.SetPropertyValues(context, properties);
}
}
在上面的代碼中查找[我在這裏放什麼?!]。這是我遇到的問題。
在成員和角色服務,他們也被初始化爲空,但他們默認設置,以便他們稱之爲之一:Membership.Provider
或Role.Provider
,但在這種情況下,因爲它不存在,我無法使用Profile.Provider
,所以我得到的是null提供者。
此外,我正在做一個良好的做法,使用配置文件會員資格?
你使用任何Ioc? – 2011-02-27 14:35:17