需要有关设计索引以跟踪未订阅系统中文档的用户的建议

发布于 2024-12-07 20:09:44 字数 1085 浏览 6 评论 0原文

我有一个项目表、一个文档表(带有项目的 FK)以及一个与项目和文档有关系的用户表。用户可以是文档的订阅者,这就是他们与文档的关系。

用户被视为项目的团队成员。一份文档一次只能分配给一个项目。只有“项目团队”的用户才能订阅文档。

在我的应用程序中,我遇到的困难是管理员能够将用户添加为文档的订阅者。但是,管理员只能从取消订阅的用户列表中进行选择。正如我上面所说,那些取消订阅的用户是项目团队的成员。

现在,我正在数据库上创建 2 个查询,以提取所有订阅用户和整个团队成员列表。然后我比较列表,只拉出未订阅的团队成员。

我不确定是否应该索引此类数据或直接从数据库中提取数据。如果我应该使用索引,则需要快速更新此数据,因为管理员需要相当快地取消订阅列表。

这就是我的查询针对 Entity Framework 4.1 的情况:

var currentSubscribers = _subscriptionRepository.Get(s => s.DocumentId == documentId).Select(s => s.Contact).ToList();

                if (projecTeamMembers != null)
                {
                    var availableSubscribers = (projecTeamMembers.Where(
                        p => !(currentSubscribers.Select(c => c.Id)).Contains(p.Id))).ToDictionary(c => c.Id, c=> c.LastName + ", " + c.FirstName);
                    return availableSubscribers;
                }
                else
                {
                    return null;
                }

这在 EF 中效果很好,但我一直在考虑使用 Lucene.Net 对我的数据建立索引,并且需要一些关于是否应该这样做的建议。

I have a table for Projects, a table for Documents (with a FK to Projects), and a table for users with a relationship to projects and documents. Users can be subscribers to a document and that is how they have a relationship to the document.

Users are considered team members on a project. A document can only assigned to one project at a time. Only users, from the "Project Team" can be subscribed to a document.

What I am struggling with, in my application, is that admins are able to add users as subscribers to a document. However, the admin can only pick from a list of unsubscribed users. Those unsubscribed users are members of the project team, like I said above.

Right now, I am creating 2 queries on my database to pull all the subscribed users and the entire list of team members. I then compare the list and only pull the team members that are not subscribed.

I am not sure if I should even index this type of data or just pull from the database directly. If I should use an index, this data needs to be updated quickly becuase the admins need that unsubscribed list rather fast.

This is what my query looks like going against Entity Framework 4.1:

var currentSubscribers = _subscriptionRepository.Get(s => s.DocumentId == documentId).Select(s => s.Contact).ToList();

                if (projecTeamMembers != null)
                {
                    var availableSubscribers = (projecTeamMembers.Where(
                        p => !(currentSubscribers.Select(c => c.Id)).Contains(p.Id))).ToDictionary(c => c.Id, c=> c.LastName + ", " + c.FirstName);
                    return availableSubscribers;
                }
                else
                {
                    return null;
                }

This works great in EF, but I have been thinking of indexing my data using Lucene.Net and need some advice on if I should do this or not.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长伴 2024-12-14 20:09:44

将此查询写入您有权访问数据库上下文的数据存储库中

var q = from m in dbContext.ProjecTeamMembers
        where !(from s in dbContext.Subscribers
                where s.DocumentId == documentId &&
                      s.Contact.Id == p.Id
                select s).Any()
        select m;

var availableSubscribers = q.ToDictionary(m => m.Id, c=> m.LastName + ", " + m.FirstName);

Write this query indide your data repository where you have access to the Database context

var q = from m in dbContext.ProjecTeamMembers
        where !(from s in dbContext.Subscribers
                where s.DocumentId == documentId &&
                      s.Contact.Id == p.Id
                select s).Any()
        select m;

var availableSubscribers = q.ToDictionary(m => m.Id, c=> m.LastName + ", " + m.FirstName);
怪我鬧 2024-12-14 20:09:44

我发现做这样的事情的最好方法是使用 Lucene.net 来保留订户索引和所有团队成员的索引。并将两者进行比较。它比每次从数据库中提取数据要快。

The best way I have found to do something like this is, using Lucene.net, is to keep an index of subscribers and an index of all team members. And compare the two. It's faster than pulling form the database each time.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文