public CredentialData GetById(long id, AasCredentialDataSO search) { CredentialData result = null; try { bool valid = true; valid = valid && IsGreaterThanZero(id); if (valid) { using (var ctx = new Base.AppContext()) { var query = ctx.CredentialDatas.AsQueryable().Where(p => p.Id == id); if (search.listCredentialDataExpression != null && search.listCredentialDataExpression.Count > 0) { foreach (var item in search.listCredentialDataExpression) { query = query.Where(item); } } result = query.SingleOrDefault(); } } } catch (Exception ex) { Logging(LogUtil.TraceData("id", id) + LogUtil.TraceData("search", search), LogType.Error); LogSystem.Error(ex); result = null; } return(result); }
public List <CredentialData> Get(AasCredentialDataSO search, CommonParam param) { List <CredentialData> list = new List <CredentialData>(); try { bool valid = true; valid = valid && IsNotNull(param); if (valid) { using (var ctx = new Base.AppContext()) { var query = ctx.CredentialDatas.AsQueryable(); if (search.listCredentialDataExpression != null && search.listCredentialDataExpression.Count > 0) { foreach (var item in search.listCredentialDataExpression) { query = query.Where(item); } } if (!string.IsNullOrWhiteSpace(search.OrderField) && !string.IsNullOrWhiteSpace(search.OrderDirection)) { if (!param.Start.HasValue || !param.Limit.HasValue) { list = query.OrderByProperty(search.OrderField, search.OrderDirection).ToList(); } else { param.Count = (from r in query select r).Count(); query = query.OrderByProperty(search.OrderField, search.OrderDirection); if (param.Count <= param.Limit.Value && param.Start.Value == 0) { list = query.ToList(); } else { list = query.Skip(param.Start.Value).Take(param.Limit.Value).ToList(); } } } else { list = query.ToList(); } } } } catch (Exception ex) { Logging(LogUtil.TraceData("search", search) + LogUtil.TraceData("param", param), LogType.Error); LogSystem.Error(ex); list.Clear(); } return(list); }
public CredentialData GetById(long id, AasCredentialDataSO search) { CredentialData result = null; try { result = GetWorker.GetById(id, search); } catch (Exception ex) { LogSystem.Error(ex); result = null; } return(result); }
public List <CredentialData> Get(AasCredentialDataSO search, CommonParam param) { List <CredentialData> result = new List <CredentialData>(); try { result = GetWorker.Get(search, param); } catch (Exception ex) { param.HasException = true; LogSystem.Error(ex); result.Clear(); } return(result); }
internal AasCredentialDataSO Query() { AasCredentialDataSO search = new AasCredentialDataSO(); try { #region Abstract Base if (this.Id.HasValue) { listExpression.Add(o => o.Id == this.Id.Value); } if (this.IsActive.HasValue) { listExpression.Add(o => o.IsActive == this.IsActive.Value); } if (this.CreateTimeFrom.HasValue) { listExpression.Add(o => o.CreateTime.Value >= this.CreateTimeFrom.Value); } if (this.CreateTimeFromGreater.HasValue) { listExpression.Add(o => o.CreateTime.Value > this.CreateTimeFromGreater.Value); } if (this.CreateTimeTo.HasValue) { listExpression.Add(o => o.CreateTime.Value <= this.CreateTimeTo.Value); } if (this.CreateTimeToLess.HasValue) { listExpression.Add(o => o.CreateTime.Value < this.CreateTimeToLess.Value); } if (this.ModifyTimeFrom.HasValue) { listExpression.Add(o => o.ModifyTime.Value >= this.ModifyTimeFrom.Value); } if (this.ModifyTimeFromGreater.HasValue) { listExpression.Add(o => o.ModifyTime.Value > this.ModifyTimeFromGreater.Value); } if (this.ModifyTimeTo.HasValue) { listExpression.Add(o => o.ModifyTime.Value <= this.ModifyTimeTo.Value); } if (this.ModifyTimeToLess.HasValue) { listExpression.Add(o => o.ModifyTime.Value < this.ModifyTimeToLess.Value); } if (!String.IsNullOrEmpty(this.Creator)) { listExpression.Add(o => o.Creator == this.Creator); } if (!String.IsNullOrEmpty(this.Modifier)) { listExpression.Add(o => o.Modifier == this.Modifier); } if (this.Ids != null) { listExpression.Add(o => this.Ids.Contains(o.Id)); } #endregion if (!String.IsNullOrWhiteSpace(this.BackendCodeExact)) { listExpression.Add(o => o.BackendCode == this.BackendCodeExact); } if (!String.IsNullOrWhiteSpace(this.TokenCodeExact)) { listExpression.Add(o => o.TokenCode == this.TokenCodeExact); } if (!String.IsNullOrWhiteSpace(this.DataKeyExact)) { listExpression.Add(o => o.DataKey == this.DataKeyExact); } search.listCredentialDataExpression.AddRange(listExpression); search.OrderField = this.OrderField; search.OrderDirection = this.OrderDirection; } catch (Exception ex) { LogSystem.Error(ex); search.listCredentialDataExpression.Clear(); search.listCredentialDataExpression.Add(o => o.Id == NegativeId); } return(search); }