具有三个表的Linq查询联接以在x天后发送警报 [英] Linq Query with three tables join to send alert after x days

查看:84
本文介绍了具有三个表的Linq查询联接以在x天后发送警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现电子邮件功能,用户可以将电子邮件发送给自20天以来未登录的个人资料,我也希望每10天重复一次.

我有三张桌子
1)维护配置文件的明细"表.
2)在通知"表中,我跟踪发送到个人资料的通知.
3)个人资料"表,用于跟踪个人资料的登录信息.

到目前为止,我已经尝试过此操作-

I want to implement email functionality where user can send email to profiles who have not logged in since 20 days also i want repeat after every 10 days.

I have three tables
1) "details" table where profile is maintained.
2) "notify" table where i keep a track of notification send to profiles.
3) "profile" table where i keep track of the login information of profile.

so far i have tried this-

list = (from c in ctx.details.AsEnumerable()
                         join u in ctx.profile.AsEnumerable()
                         join a in ctx.notify..AsEnumerable()
                         on c.profileid equals u.profileid equals a.profileid
                         where (u.last_login_date == null &&
                        (DateTime.Now - u.last_login_date).TotalDays >= 20)
                         select new details
                         {
                             profileid = c.profileid.ToString(),
                             firstname = c.firstname,
                             lastname = c.lastname,
                             email = c.email

                         }).ToList();


-


-

My tables are ->
        details             notify                profile
        -----------        ------------          --------------
        profileid          profileid              profileid
        firstname          alert_date(datetime)   last_login_date(datetime)
        lastname
        email



如果alert_date是较早发送电子邮件的日期,last_login_date是
,则该日期为
他最后一次登录个人资料的日期.

但是我确定这是行不通的.我希望在明细表中填充明细.
帮帮我.



where the alert_date is the date if he has been send email earlier and last_login_date is
the date when he has lastly login in the profile.

But I am sure this is not going to work.I want the details table to be filled with details.
Help me out.

推荐答案

使用 Quartz.NET 进行作业调度


在需要连接三个表的情况下,请验证数据库是否已规范化.在我的情况下,数据库没有被规范化,因此确实遇到了这种情况.
后来我更改了数据库结构,并解决了根本不需要应用连接的问题.

谢谢大家
石头
Well in such cases where three tables need to be joined, please verify that the database is normalised or not.In my case it was not and hence did came across such situation.

I later changed the database structure and solved the problem where I don''t have to apply join at all.

Thanks everyone
Stone


这篇关于具有三个表的Linq查询联接以在x天后发送警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆