/// <summary> /// 本周请假信息 /// </summary> /// <returns></returns> public JsonResult WeekLeave(string grade, int rows, int pagesize) { int page = (pagesize - 1) * rows; var a = (from LeaveInfoes in db.LeaveInfo where ! ((from LeaveInfoes0 in db.LeaveInfo where SqlFunctions.DateDiff("dd", LeaveInfoes0.BeginDate, SqlFunctions.GetDate()) <= 7 && LeaveInfoes0.GNum == grade select new { LeaveInfoes0.Lid }).Take(page)).Contains(new { Lid = LeaveInfoes.Lid }) && SqlFunctions.DateDiff("dd", LeaveInfoes.BeginDate, SqlFunctions.GetDate()) <= 7 && LeaveInfoes.GNum == grade select new { Lid = LeaveInfoes.Lid, StuNum = LeaveInfoes.StuNum, StuName = LeaveInfoes.StuName, Phone = LeaveInfoes.Phone, GNum = LeaveInfoes.GNum, CName = LeaveInfoes.CName, BeginDate = LeaveInfoes.BeginDate, EndDate = LeaveInfoes.EndDate, Addresss = LeaveInfoes.Addresss, Reason = LeaveInfoes.Reason, Principal = LeaveInfoes.Principal, Statu = LeaveInfoes.Statu }).Take(rows); return(Json(a, JsonRequestBehavior.AllowGet)); }
public override IEnumerable <InformativoViewModel> Bind(int?index, int pageSize = 50, params object[] param) { int informativoID = 0; if (param[0] != null) { informativoID = (int)param[0]; } return((from info in db.Informativos where info.DataPublicacao <= SqlFunctions.GetDate() && info.DataExpiracao >= SqlFunctions.GetDate() && info.InformativoID == informativoID orderby info.DataPublicacao descending select new InformativoViewModel { InformativoID = info.InformativoID, DataExpiracao = info.DataExpiracao, DataInformativo = info.DataInformativo, DataPublicacao = info.DataPublicacao, Cabecalho = info.Cabecalho, Resumo = info.Resumo, MensagemDetalhada = info.MensagemDetalhada, }).ToList()); }
public async Task <bool> UpdateAppointment(AppointmenTO filtro) { List <AppointmenTO> appointmentsByPacient = new List <AppointmenTO>(); using (AppointmentsEntities dbContext = new AppointmentsEntities()) { appointmentsByPacient = await(from app in dbContext.Appointments join pat in dbContext.Pacients on app.IdKeyPacient equals pat.IdKey where app.IdKeyPacient == filtro.IdKeyPacient && app.IdKey == filtro.IdKey && DbFunctions.DiffHours(app.Date, SqlFunctions.GetDate().Value) <= 24 select app).ProjectTo <AppointmenTO>().ToListAsync(); if (appointmentsByPacient.Count <= 0) { Appointment AppointmentUpdate = Mapper.Map <Appointment>(filtro); dbContext.Appointments.Attach(AppointmentUpdate); var entry = dbContext.Entry(AppointmentUpdate); entry.Property(e => e.IdState).IsModified = true; // other changed properties dbContext.SaveChanges(); } else { return(false); } } return(true); }
/// <summary> /// 扩展方法,自带方法不能满足的时候可以添加新方法 /// </summary> /// <returns></returns> public DateTime GetDate() { var now = this.Entities.Select(t => SqlFunctions.GetDate()).FirstOrDefault(); if (!now.HasValue) { now = new DateTime(1900, 1, 1, 0, 0, 0); } return(now.Value); }
// GET: Form public ActionResult Index() { QvApp_RawdaDeductionEntities3 context = new QvApp_RawdaDeductionEntities3(); var EndDays = 30; var data = from form in context.DUC_Form where SqlFunctions.DateDiff("day", SqlFunctions.GetDate(), form.EndDate) < EndDays && SqlFunctions.DateDiff("day", SqlFunctions.GetDate(), form.EndDate) > 0 select form.EndDate; ViewBag.forms = data; return(View()); }
public ActionResult SearchByDays(DaysModel model) { QvApp_RawdaDeductionEntities3 context = new QvApp_RawdaDeductionEntities3(); var EndDays = model.numOfDaysToEnd; var data = from form in context.DUC_Form where SqlFunctions.DateDiff("day", SqlFunctions.GetDate(), form.EndDate) < EndDays && SqlFunctions.DateDiff("day", SqlFunctions.GetDate(), form.EndDate) > 0 select form; ViewBag.forms = data; return(View("SearchByDaysResult")); }
private IQueryable <SuggestionValue> RetrieveSuggestions(ApplicationUser user) { return( from sg in db.Suggestions join us in db.UserSuggestions.Include("Status") on sg.Id equals us.SuggestionId into us_sg from j in us_sg.DefaultIfEmpty() where ( ( j.Status != SuggestionStatus.Completed && j.Status != SuggestionStatus.NotToday && j.Status != SuggestionStatus.NeverAsk ) || ( j.Status == SuggestionStatus.NotToday && SqlFunctions.DateDiff("day", j.DTAdded, SqlFunctions.GetDate()) > 1 ) && j.UserId == user.Id ) select new SuggestionValue { Suggestion = sg, Value = SqlFunctions.Exp( ( ( from q in ( sg.Suggestions.Select(q => q.Question) ) join uq in db.UserQuestions on q.Id equals uq.QuestionId where uq.UserId == user.Id select uq.Response ) .DefaultIfEmpty() ) .Select(i => SqlFunctions.Log(i + 0.000001)) .DefaultIfEmpty() .Sum() ), Status = j.Status } ); }
private void btnFunction_Click(object sender, EventArgs e) { using (UnitOfWork uof = new UnitOfWork(new NorthwindEntities())) { //呼叫純量值函數 var query = (from emp in uof.Repository <Employees>().GetAll() where NorthwindDbFunctions.fn_retEmployeeName(emp.EmployeeID) == "Leverling Janet" select new { EmployeeId = emp.EmployeeID, NameFirstChar = DbFunctions.Left(emp.FirstName, 1), DbTime = SqlFunctions.GetDate() }).ToList(); DataGridView1.DataSource = query; } }
public List <cBanner> GetBanners() { List <cBanner> banners = _context.ACAD_BANNERS .Where(x => x.CD_ACADEMIA == _enterpriseId && x.FL_ATIVO == true && SqlFunctions.GetDate() >= x.DT_INICIO && SqlFunctions.GetDate() <= x.DT_FINAL.Value) .Select(x => new cBanner() { bannerId = x.CD_BANNER, mainCaption = x.TX_CAPTION, secondaryCaption = x.TX_CAPTION2 }) .OrderBy(x => Guid.NewGuid()).ToList(); return(banners); }
/// <summary> /// 今日请假人数 /// </summary> /// <returns></returns> public JsonResult TodayTotal() { var a = from LeaveInfoes in (from LeaveInfoes in db.LeaveInfo where SqlFunctions.DateDiff("dd", LeaveInfoes.BeginDate, SqlFunctions.GetDate()) == 0 select new { Dummy = "x" }) group LeaveInfoes by new { LeaveInfoes.Dummy } into g select new { total = g.Count() }; return(Json(a, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 本周销假人数 /// </summary> /// <returns></returns> public JsonResult WeekXj() { var a = from LeaveInfoes in (from LeaveInfoes in db.LeaveInfo where SqlFunctions.DateDiff("dd", LeaveInfoes.EndDate, SqlFunctions.GetDate()) <= 7 && LeaveInfoes.Statu == 1 select new { Dummy = "x" }) group LeaveInfoes by new { LeaveInfoes.Dummy } into g select new { xjTotal = g.Count() }; return(Json(a, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 本月请假数量 /// </summary> /// <returns></returns> public JsonResult MonthTotal(string grade) { var a = from LeaveInfoes in (from LeaveInfoes in db.LeaveInfo where LeaveInfoes.GNum == grade && SqlFunctions.DateDiff("mm", LeaveInfoes.BeginDate, SqlFunctions.GetDate()) == 0 select new { Dummy = "x" }) group LeaveInfoes by new { LeaveInfoes.Dummy } into g select new { total = g.Count() }; return(Json(a, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 本周请假数量 /// </summary> /// <returns></returns> public JsonResult WeekTotal(string grade, string cla) { var a = from LeaveInfoes in (from LeaveInfoes in db.LeaveInfo where LeaveInfoes.CName == cla && LeaveInfoes.GNum == grade && SqlFunctions.DateDiff("dd", LeaveInfoes.BeginDate, SqlFunctions.GetDate()) <= 7 select new { Dummy = "x" }) group LeaveInfoes by new { LeaveInfoes.Dummy } into g select new { total = g.Count() }; return(Json(a, JsonRequestBehavior.AllowGet)); }
public object GetFiltered(Location location, int radius, string name = "", List <int> types = null, List <DateTime> dates = null) { if (dates != null && types != null) { DateTime fromDate = dates.First(); DateTime toDate = dates.Last(); return(Event.Where(w => (SqlFunctions.SquareRoot(Math.Pow(w.Longitude - location.Longitude, 2) + Math.Pow(w.Latitude - location.Latitude, 2)) <= radius / 111139) && (string.IsNullOrEmpty(name) || w.Name == name) && (types.Contains(w.TypeId)) && (w.Date > fromDate && w.Date < toDate) ).Select(s => new { s.Id, s.Name, s.Description, s.Date, s.TypeId, s.Longitude, s.Latitude }).ToList()); } else if (dates == null && types != null) { return(Event.Where(w => (SqlFunctions.SquareRoot(Math.Pow(w.Longitude - location.Longitude, 2) + Math.Pow(w.Latitude - location.Latitude, 2)) <= radius / 111139) && (string.IsNullOrEmpty(name) || w.Name == name) && (types.Count == 0 || types.Contains(w.TypeId)) && (w.Date > SqlFunctions.GetDate()) ).Select(s => new { s.Id, s.Name, s.Description, s.Date, s.TypeId, s.Longitude, s.Latitude }).ToList()); } else if (dates != null && types == null) { DateTime fromDate = dates.First(); DateTime toDate = dates.Last(); return(Event.Where(w => (SqlFunctions.SquareRoot(Math.Pow(w.Longitude - location.Longitude, 2) + Math.Pow(w.Latitude - location.Latitude, 2)) <= radius / 111139) && (string.IsNullOrEmpty(name) || w.Name == name) && (w.Date > fromDate && w.Date < toDate) ).Select(s => new { s.Id, s.Name, s.Description, s.Date, s.TypeId, s.Longitude, s.Latitude }).ToList()); } else { return(Event.Where(w => (SqlFunctions.SquareRoot(Math.Pow(w.Longitude - location.Longitude, 2) + Math.Pow(w.Latitude - location.Latitude, 2)) <= radius / 111139) && (string.IsNullOrEmpty(name) || w.Name == name) && (w.Date > SqlFunctions.GetDate()) ).Select(s => new { s.Id, s.Name, s.Description, s.Date, s.TypeId, s.Longitude, s.Latitude }).ToList()); } }
public override IEnumerable <InformativoViewModel> Bind(int?index, int pageSize = 50, params object[] param) { DateTime data1 = param.Count() > 0 && param[0] != null ? (DateTime)param[0] : new DateTime(1980, 1, 1); DateTime data2 = param.Count() > 1 && param[1] != null ? (DateTime)param[1] : Funcoes.Brasilia().Date.AddDays(30); string EdificacaoID = ""; string GrupoCondominoID = ""; string IsHome = "N"; if (param.Count() > 2) { IsHome = "S"; if (param[2] != null) { int[] GrupoCondomino = (int[])param[2]; for (int i = 0; i <= GrupoCondomino.Count() - 1; i++) { GrupoCondominoID += GrupoCondomino[i].ToString() + ";"; } } if (param[3] != null) { IEnumerable <Unidade> Unidades = (IEnumerable <Unidade>)param[3]; foreach (var unidade in Unidades) { EdificacaoID += unidade.EdificacaoID.ToString().Trim() + ";"; } } } return((from info in db.Informativos join gru in db.GrupoCondominos on info.GrupoCondominoID equals gru.GrupoCondominoID into GRU from gru in GRU.DefaultIfEmpty() join edi in db.Edificacaos on info.EdificacaoID equals edi.EdificacaoID into EDI from edi in EDI.DefaultIfEmpty() where info.DataPublicacao <= SqlFunctions.GetDate() && info.CondominioID == sessaoCorrente.empresaId && (IsHome == "N" || info.DataExpiracao >= SqlFunctions.GetDate()) && (GrupoCondominoID == "" || !info.GrupoCondominoID.HasValue || (info.GrupoCondominoID.HasValue && GrupoCondominoID.Contains(SqlFunctions.StringConvert((double)info.GrupoCondominoID).Trim()))) && (EdificacaoID == "" || !info.EdificacaoID.HasValue || (info.EdificacaoID.HasValue && EdificacaoID.Contains(SqlFunctions.StringConvert((double)info.EdificacaoID).Trim()))) orderby info.DataPublicacao descending select new InformativoViewModel { empresaId = sessaoCorrente.empresaId, InformativoID = info.InformativoID, CondominioID = info.CondominioID, EdificacaoID = info.EdificacaoID, descricao_edificacao = edi.Descricao, GrupoCondominoID = gru.GrupoCondominoID, descricao_GrupoCondomino = gru.Descricao, DataExpiracao = info.DataExpiracao, DataInformativo = info.DataInformativo, DataPublicacao = info.DataPublicacao, Cabecalho = info.Cabecalho, Resumo = info.Resumo, MensagemDetalhada = info.MensagemDetalhada, InformativoAnuncio = info.InformativoAnuncio, Comentarios = (from com in db.InformativoComentarios join con in db.Condominos on com.CondominoID equals con.CondominoID join cu in db.CondominoUnidades on new { con.CondominioID, con.CondominoID } equals new { cu.CondominioID, cu.CondominoID } join ed in db.Edificacaos on cu.EdificacaoID equals ed.EdificacaoID where com.InformativoID == info.InformativoID && cu.DataFim == null select new InformativoComentarioViewModel() { InformativoID = info.InformativoID, DataComentario = com.DataComentario, CondominoID = com.CondominoID, Nome = con.Nome, EdificacaoID = ed.EdificacaoID, DescricaoEdificacao = ed.Descricao, UnidadeID = cu.UnidadeID, Descricao = com.Descricao, DataDesativacao = com.DataDesativacao, Motivo = com.Motivo }).ToList(), PageSize = pageSize, TotalCount = (from info1 in db.Informativos join gru1 in db.GrupoCondominos on info1.GrupoCondominoID equals gru1.GrupoCondominoID into GRU1 from gru1 in GRU1.DefaultIfEmpty() join edi1 in db.Edificacaos on info1.EdificacaoID equals edi1.EdificacaoID into EDI1 from edi1 in EDI1.DefaultIfEmpty() where info.DataPublicacao <= SqlFunctions.GetDate() && info1.CondominioID == sessaoCorrente.empresaId && (IsHome == "N" || info1.DataExpiracao >= SqlFunctions.GetDate()) && (GrupoCondominoID == "" || !info1.GrupoCondominoID.HasValue || (info1.GrupoCondominoID.HasValue && GrupoCondominoID.Contains(SqlFunctions.StringConvert((double)info1.GrupoCondominoID).Trim()))) && (EdificacaoID == "" || !info1.EdificacaoID.HasValue || (info1.EdificacaoID.HasValue && EdificacaoID.Contains(SqlFunctions.StringConvert((double)info1.EdificacaoID).Trim()))) orderby info1.DataPublicacao descending select info1).Count() }).Skip((index ?? 0) * pageSize).Take(pageSize).ToList()); }
private static object GetDbTime <T>(DbContext db) where T : class { return(db.Set <T>().Select(n => SqlFunctions.GetDate()).FirstOrDefault()); }
public ActionResult Index() { LoginCredentials LG = new LoginCredentials(); LG.swg = System.Web.HttpContext.Current.Session["swgId"] as String; System.Web.HttpContext.Current.Session["role"] = LoginController.role(); if (System.Web.HttpContext.Current.Session["role"].ToString() == "null") { return(Content("Not Authorized User")); } DateTime value = new DateTime(1900, 1, 1); string MgrId = System.Web.HttpContext.Current.Session["swgId"].ToString(); List <EmployeeClass> ecl = new List <EmployeeClass>(); #region api //* GET list sample string url = "http://localhost:26091/api/departments"; HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url); GETRequest.Method = "GET"; GETRequest.ContentType = "application/json"; var getResponse = (HttpWebResponse)GETRequest.GetResponse(); Stream getResponseStream = getResponse.GetResponseStream(); StreamReader sr = new StreamReader(getResponseStream); var responseFromServer = sr.ReadToEnd(); List <Department> departments = JsonConvert.DeserializeObject <List <Department> >(responseFromServer); foreach (var dep in departments) { int id = dep.DepartmentId; string depName = dep.DepartmentName; } // /* GET from uri sample * string url = "http://localhost:26091/api/departments/20"; * System.Net.HttpWebRequest GETRequest = (HttpWebRequest)WebRequest.Create(url); * GETRequest.Method = "GET"; * GETRequest.ContentType = "application/json"; * var getResponse = (HttpWebResponse)GETRequest.GetResponse(); * Stream getResponseStream = getResponse.GetResponseStream(); * StreamReader sr = new StreamReader(getResponseStream); * var responseFromServer = sr.ReadToEnd(); * * Department department = JsonConvert.DeserializeObject<Department>(responseFromServer); * * int id = department.DepartmentId; * string depName = department.DepartmentName; */ /* POST sample * string url = "http://localhost:26091/api/departments"; * HttpWebRequest POSTRequest = (HttpWebRequest)WebRequest.Create(url2); * POSTRequest.Method = "POST"; * POSTRequest.ContentType = "application/json"; * Department dep2 = new Department(97, "from code - department"); * string serializedDep2 = JsonConvert.SerializeObject(dep2); * byte[] byteArray = System.Text.Encoding.UTF8.GetBytes(serializedDep2); * POSTRequest.ContentLength = byteArray.Length; * POSTRequest.Connection = "true"; * Stream dataStream = POSTRequest.GetRequestStream(); * dataStream.Write(byteArray, 0, byteArray.Length); * dataStream.Close(); * * HttpWebResponse response = (HttpWebResponse)POSTRequest.GetResponse(); * dataStream = response.GetResponseStream(); * StreamReader reader = new StreamReader(dataStream); * string responseFromServer2 = HttpUtility.UrlDecode(reader.ReadToEnd()); * dataStream.Close(); */ /* DELETE from uri sample * string url3 = "http://localhost:26091/api/departments/98"; * System.Net.HttpWebRequest DELETERequest = (HttpWebRequest)WebRequest.Create(url3); * DELETERequest.Method = "DELETE"; * DELETERequest.ContentType = "application/json"; * * DELETERequest.Connection = "true"; * Stream dataStream3 = DELETERequest.GetRequestStream(); * * HttpWebResponse response3 = (HttpWebResponse)DELETERequest.GetResponse(); * dataStream3 = response3.GetResponseStream(); * StreamReader reader3 = new StreamReader(dataStream3); * string responseFromServer3 = HttpUtility.UrlDecode(reader3.ReadToEnd()); * dataStream3.Close(); */ /* DELETE from body sample * string url3 = "http://localhost:26091/api/departments"; * System.Net.HttpWebRequest DELETERequest = (HttpWebRequest)WebRequest.Create(url3); * DELETERequest.Method = "DELETE"; * DELETERequest.ContentType = "application/json"; * //Department dep2 = new Department(97, "from code - department"); * int depId = 99; * string serializedDep3 = JsonConvert.SerializeObject(depId); * byte[] byteArray3 = System.Text.Encoding.UTF8.GetBytes(serializedDep3); * DELETERequest.ContentLength = byteArray3.Length; * DELETERequest.Connection = "true"; * Stream dataStream3 = DELETERequest.GetRequestStream(); * dataStream3.Write(byteArray3, 0, byteArray3.Length); * dataStream3.Close(); * * HttpWebResponse response3 = (HttpWebResponse)DELETERequest.GetResponse(); * dataStream3 = response3.GetResponseStream(); * StreamReader reader3 = new StreamReader(dataStream3); * string responseFromServer3 = HttpUtility.UrlDecode(reader3.ReadToEnd()); * dataStream3.Close(); */ /* PUT Sample * string url5 = "http://localhost:26091/api/departments"; * System.Net.HttpWebRequest PUTRequest = (HttpWebRequest)WebRequest.Create(url5); * PUTRequest.Method = "PUT"; * PUTRequest.ContentType = "application/json"; * Department dep5 = new Department(97, "department 97"); * string serializedDep5 = JsonConvert.SerializeObject(dep5); * byte[] byteArray5 = System.Text.Encoding.UTF8.GetBytes(serializedDep5); * PUTRequest.ContentLength = byteArray5.Length; * PUTRequest.Connection = "true"; * Stream dataStream5 = PUTRequest.GetRequestStream(); * dataStream5.Write(byteArray5, 0, byteArray5.Length); * dataStream5.Close(); * * HttpWebResponse response5 = (HttpWebResponse)PUTRequest.GetResponse(); * dataStream5 = response5.GetResponseStream(); * StreamReader reader5 = new StreamReader(dataStream5); * string responseFromServer5 = HttpUtility.UrlDecode(reader5.ReadToEnd()); * dataStream5.Close(); */ #endregion var data = context.JobTitles.Join(context.Emps, j => j.JobId, e => e.JobId, (j, e) => new { JobTitles = j, Emps = e }). Join(context.Depts, e => e.Emps.DeptId, d => d.DeptId, (e, d) => new { Emps = e, Depts = d }). Join(context.Products, e => e.Emps.Emps.ProductId, p => p.ProductId, (e, p) => new { Emps = e, Products = p }). Where(ssa => ssa.Emps.Emps.Emps.ManagerId == MgrId && (string.IsNullOrEmpty(ssa.Emps.Emps.Emps.DOL.ToString()) || SqlFunctions.DateDiff("day", ssa.Emps.Emps.Emps.DOL, value) == 0 || ssa.Emps.Emps.Emps.DOL >= SqlFunctions.GetDate())). Select(ssa => new { ssa.Emps.Emps.Emps.SWG, ssa.Emps.Emps.Emps.Name, ssa.Emps.Emps.JobTitles.JobTitle1, ssa.Emps.Depts.DeptName, ssa.Products.ProductName, ssa.Emps.Emps.Emps.ManagerId, ssa.Emps.Emps.Emps.DOJ, ssa.Emps.Emps.Emps.Email, ssa.Emps.Emps.Emps.DOR, ssa.Emps.Emps.Emps.DOL, ssa.Emps.Emps.Emps.DOO }); foreach (var o in data) { EmployeeClass temp = new EmployeeClass(); temp.swg = o.SWG; temp.name = o.Name; temp.jobTitle = o.JobTitle1; temp.deptName = o.DeptName; temp.product = o.ProductName; temp.manager = o.ManagerId; temp.dateOfJoining = o.DOJ; temp.email = o.Email; temp.dateOfResignation = o.DOR; temp.lastDay = o.DOL; temp.dateOfOffer = o.DOO; ecl.Add(temp); } //DBManager db = new DBManager(); //ViewBag.MgrId = MgrId; //var data1 = db.GetMyTeam(MgrId); if (System.Web.HttpContext.Current.Session["swgId"] == null) { RedirectToAction("Index", "Login"); } //return View("Index", data); return(View("Index", ecl)); }
public override IEnumerable <EmailLogViewModel> Bind(int?index, int pageSize = 50, params object[] param) { DateTime data1 = param.Count() > 0 && param[0] != null ? (DateTime)param[0] : new DateTime(1980, 1, 1); DateTime data2 = param.Count() > 1 && param[1] != null ? (DateTime)param[1] : Funcoes.Brasilia().Date.AddDays(30); string EdificacaoID = ""; string GrupoCondominoID = ""; string IsHome = "N"; if (param.Count() > 2) { IsHome = "S"; if (param[2] != null) { int[] GrupoCondomino = (int[])param[2]; for (int i = 0; i <= GrupoCondomino.Count() - 1; i++) { GrupoCondominoID += GrupoCondominoID[i].ToString() + ";"; } } if (param[3] != null) { IEnumerable <Unidade> Unidades = (IEnumerable <Unidade>)param[3]; foreach (var unidade in Unidades) { EdificacaoID += unidade.EdificacaoID + ";"; } } } IEnumerable <EmailLogViewModel> foldase = (from info in db.EmailLogs join gru in db.GrupoCondominos on info.GrupoCondominoID equals gru.GrupoCondominoID into GRU from gru in GRU.DefaultIfEmpty() join edi in db.Edificacaos on info.EdificacaoID equals edi.EdificacaoID into EDI from edi in EDI.DefaultIfEmpty() join eti in db.EmailTipos on info.EmailTipoID equals eti.EmailTipoID where info.DataEmail >= data1 && info.DataEmail <= data2 && info.CondominioID == SessaoLocal.empresaId && (IsHome == "N" || info.DataEmail >= SqlFunctions.GetDate()) && (GrupoCondominoID == "" || GrupoCondominoID.Contains(info.GrupoCondominoID.ToString())) && (EdificacaoID == "" || EdificacaoID.Contains(info.EdificacaoID.ToString())) && (eti.CondominioID == SessaoLocal.empresaId) orderby info.DataEmail descending select new EmailLogViewModel { empresaId = sessaoCorrente.empresaId, EmailLogID = info.EmailLogID, CondominioID = info.CondominioID, EdificacaoID = info.EdificacaoID, Descricao_Edificacao = edi.Descricao, GrupoCondominoID = gru.GrupoCondominoID, Descricao_GrupoCondomino = gru.Descricao, DataEmail = info.DataEmail, Assunto = info.Assunto, EmailMensagem = info.EmailMensagem, EmailTipoID = info.EmailTipoID, UnidadeID = info.UnidadeID, sessionId = sessaoCorrente.sessaoId, Descricao_EmailTipo = eti.Descricao, }).ToList(); int contador = 0; foreach (EmailLogViewModel log in foldase) { if (log.UnidadeID.HasValue) { foldase.ElementAt(contador).Codigo = db.Unidades.Find(log.CondominioID, log.EdificacaoID, log.UnidadeID).Codigo; } contador++; } return(foldase); }
public F_OrderDTO Create(F_OrderDTO dto) { int count = this._IF_OrderRepository.Data.Where(item => SqlFunctions.DateDiff("day", item.CreatedDate, SqlFunctions.GetDate()) == 0).Count(); dto.Code = string.Format("GFQ{0}{1}", DateTime.Now.ToString("yyyyMMdd"), string.Format("{0:D4}", (count + 1))); return(base.F_Create <F_OrderDTO, F_Order>(dto , _IF_OrderRepository , dtoAction => { })); }
//public async Task<List<T>> GetListAdultsAsync() //{ // // return dbSet.Where(p =>SqlFunctions.DateDiff("day",p.ConsumerDateofBirth, SqlFunctions.GetDate()) > 1000); // //(p => SqlFunctions.DateDiff("day", SqlFunctions.GetDate(), SqlFunctions.GetDate()) < 18).ToListAsync(); // / 365.2425 // // return dbSet.Where(p => p. > 50 && p.TValue < 70 || p.Currency != "PLN").AsQueryable(); // DateTime currentDate = DateTime.Now.AddYears(-18); // return await dbSet.Where(p => p.ConsumerDateofBirth == currentDate).ToListAsync(); //} public IQueryable <T> FindBy(Expression <Func <T, bool> > predicate) { //return dbSet.Where(p => p.TValue > 50 && p.TValue < 70 || p.Currency != "PLN").AsQueryable(); // return dbSet.Where(predicate).AsQueryable(); return(dbSet.Where(p => SqlFunctions.DateDiff("day", p.ConsumerDateofBirth, SqlFunctions.GetDate()) > 1000)); }
public int GetMessageCount(Guid referenceId) { ISpecification <F_Activity> spec = Specification <F_Activity> .Eval(item => true); spec = new AndSpecification <F_Activity>(spec, Specification <F_Activity> .Eval(item => referenceId == null || item.ReferenceId.Equals(referenceId))); spec = new AndSpecification <F_Activity>(spec, Specification <F_Activity> .Eval(item => !item.IsRead)); spec = new AndSpecification <F_Activity>(spec, Specification <F_Activity> .Eval(item => SqlFunctions.DateDiff("day", item.CreatedDate, SqlFunctions.GetDate()) <= 7)); return(this._IF_ActivityRepository.GetAll(spec).Count()); }
public List <F_ADDTO> GetAll(string [] codes) { ISpecification <F_AD> spec = Specification <F_AD> .Eval(item => true); spec = new AndSpecification <F_AD>(spec, Specification <F_AD> .Eval(item => codes.Contains(item.Code))); spec = new AndSpecification <F_AD>(spec, Specification <F_AD> .Eval(item => item.IsActive)); spec = new AndSpecification <F_AD>(spec, Specification <F_AD> .Eval(item => !item.BeginDate.HasValue || item.BeginDate.HasValue && item.BeginDate.Value <= SqlFunctions.GetDate().Value )); spec = new AndSpecification <F_AD>(spec, Specification <F_AD> .Eval(item => !item.EndDate.HasValue || item.EndDate.HasValue && item.EndDate.Value >= SqlFunctions.GetDate().Value )); var list = new List <F_ADDTO>(); this._IF_ADRepository.GetAll(spec).ToList().ForEach(item => list.Add(Mapper.Map <F_AD, F_ADDTO>(item)) ); return(list); }
//取数据库时间 private static void Method11() { Console.WriteLine(_container.GetExportedValue <IUserFormService>().Users().Select(u => SqlFunctions.GetDate()).First().Value); }
//添加 private static void Method03() { DateTime dt = _container.GetExportedValue <IUserFormService>().Users().Select(u => SqlFunctions.GetDate()).First().Value; User user = new User(); user.AddDate = dt; user.eattribute1 = "123"; user.IsDeleted = false; user.mdate = dt; user.muser = "******"; user.usercode = "65128044"; user.userdepart = "123"; user.useremail = "123"; user.username = "******"; user.userpwd = "123"; user.userstat = "123"; user.usertel = "123"; try { Console.WriteLine(_container.GetExportedValue <IUserFormService>().AddEntity(user).Message); } catch (DbEntityValidationException e) { Console.WriteLine(e.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage); } }