DateTime.AddDays()不能在Linq中使用sql查询

时间:2016-02-29 12:54:20

标签: asp.net sql-server linq-to-sql

我正在尝试在创建日期中添加一天(数据库表成员),然后与当前日期进行比较,这是我的代码

 public List<DOlead> getInactiveLeads(DateTime Start, DateTime End, DOuser user)
    {
        List<lead> ObjLeads = new List<lead>();
        List<DOlead> ObjLead = new List<DOlead>();
        company comobj = _Context.companies.Where(x => x.id == user.company_id).FirstOrDefault();
        ObjLead = (from le in _Context.leads
                    join leadstatus in _Context.leads_status on le.lead_status_id equals leadstatus.id
                    join leadsource in _Context.lead_source on le.lead_source_id equals leadsource.id
                    join leadindustry in _Context.industries on le.industry_id equals leadindustry.id
                    where le.is_converted == false && le.date_created.AddDays(Convert.ToDouble(comobj.no_activity)) < DateTime.Today && le.date_created.Value.Date<Start && le.date_created.Value.Date>End
                    select new DOlead
                    {
                        id = le.id,
                        title = le.title,
                        is_converted = le.is_converted,
                        street_address = le.street_address,
                        email = le.email,
                        lead_name = le.lead_name,
                        first_name = le.first_name,
                        middle_name = le.middle_name,
                        last_name = le.last_name,
                        phone_num = le.phone_num,
                        postal_code = le.postal_code,
                        city = le.city,
                        state = le.state,
                        country = le.country,
                        lead_owner_id = le.lead_owner_id,
                        lead_status_name = leadstatus.lead_status_name,
                        lead_source_name = leadsource.lead_source_name,
                        employees = le.employees,
                        industry_name = leadindustry.industry_name,
                        lead_date = le.lead_date,
                        createdby_id = le.createdby_id,
                        date_created = le.date_created,
                        industry_id = le.industry_id,
                        lead_status_id = le.lead_status_id,
                        lead_source_id = le.lead_source_id,

                    }).OrderByDescending(x => x.title).ToList();


        return ObjLead;

        //return Mapper.Map<List<DOlead>>(ObjLeads);
    }

但它在AddDays方法

上显示错误

其中le.is_converted == false&amp;&amp; le.date_created.AddDays(Convert.ToDouble(comobj.no_activity))&lt; DateTime.Today&amp;&amp; le.date_created.Value.DateEnd

错误:

  

的DateTime?不包含AddDays方法的定义。

0 个答案:

没有答案