问题描述
ASP.NET 2.0的会员,角色和配置文件是猫的喵。对于角色的API支持方便的方法,如
GetAllUsersInRole(MyNewsletterSubscriber),这将在MyNewsletterSubscriber角色返回的人的集合。
ASP.NET 2.0 membership, roles, and profiles is the cat's meow. The API for roles supports handy methods likeGetAllUsersInRole("MyNewsletterSubscriber"), which will return a collection of people in the "MyNewsletterSubscriber" role.
我想知道什么是最好的方式返回的人收集自定义ASP.NET配置文件属性可能。因此,例如,我可能会创建一个名为IsNewsletter1SubscriptionUserSelectionTextOnly自定义配置文件属性和另一个名为IsNewsletter1UserSelectionMobileOptimized的自定义配置文件属性。
I am wondering what the best way to return a collection of people with custom ASP.NET Profile properties might be. So for example, I might create one custom profile property called IsNewsletter1SubscriptionUserSelectionTextOnly and another custom profile property called IsNewsletter1UserSelectionMobileOptimized.
如何的话,我可以最有效地查询到GetAllUsersWithCustomProfileProperty类似的东西(IsNewsletter1SubscriptionUserSelectionTextOnly,真正的);
How then, can I most efficiently query for something akin to GetAllUsersWithCustomProfileProperty("IsNewsletter1SubscriptionUserSelectionTextOnly", true);
有关我预想的使用,各地型材API似乎不发达 - 我认为斯科特·格思里在他2006年的TechEd谈话中提到它的一些即将开展的工作,但我不知道发生了什么已经完成。
For the use I'm envisioning, the API around Profiles seems underdeveloped -- I think Scott Guthrie mentioned some forthcoming work on it at his talk at Tech Ed 2006, but I don't know what's been done.
这也可能是我试图不适当地使用配置文件,这将是更好地应对所有存储这个垃圾直角色。不知道。我喜欢用角色或型材列表管理的想法,但我不知道要管理它最彻底的方法。
It may also be that I'm trying to use Profiles inappropriately, and it would be better to store all of this junk as straight roles. Don't know. I like the idea of using Roles or Profiles for list management, but I don't know the cleanest way to manage it.
思想,观念,答案?谢谢...
Thoughts, idea, answers? Thanks...
推荐答案
好了,上查询型材 - 至少是默认的SQL执行 - 是可怕的,因为你真的在查询的二进制序列化的领域,使每个查询需求加载数据库中的每一行,反序列化二进制表示,然后检查答案。所以,不要欺骗和LINQ做它的对象或东西,你的DBA会拍你。
Well, querying on profiles--at least with the default SQL implementation--is scary because you are really querying on a binary serialized field, so every query needs to load every row in the database, deserialize said binary and then check the answer. So don't cheat and do it with LINQ to Objects or something, your DBA will shoot you.
总之,我的规则,只要你想在个人查询,你最好实现一个自定义提供程序以正常方式可查询。通常这最终被域模型的一部分。
Anyhow, my rule is as soon as you want to query on profile, you had better implement a custom provider that is queryable in a normal fashion. Usually this ends up being part of the domain model.
这篇关于ASP.NET角色和配置文件:最好的方式来查询谁匹配的自定义配置文件属性的用户集合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!