public TObject GetObject <TObject>(string key, bool useCache = false) where TObject : class { TObject LoadData() { TObject result = default(TObject); var setting = Get(key, useCache); if (setting != null && !String.IsNullOrEmpty(setting.StrValue)) { result = JsonSerializationUtility.Deserialize <TObject>(setting.StrValue); } return(result); } if (useCache) { string cacheKeyToUse = CreateCacheKeyForThisType(key + "_object"); TObject result = default(TObject); if (!Cache.TryGetValue(cacheKeyToUse, out result)) { result = LoadData(); if (result != null) { Cache.Save(cacheKeyToUse, result, CacheExpiration); } } return(result); } return(LoadData()); }
internal static void FillEntityForGet(NormalizedStatement entity) { if (entity.StatementDefinitionData != null) { entity.StatementDefinition = JsonSerializationUtility.Deserialize <StatementDefinition>(entity.StatementDefinitionData); } }
public void SetObject <TObject>(string key, TObject data) where TObject : class { using (var context = CreateContextFunc()) { string strData = null; if (data != null) { strData = JsonSerializationUtility.Serialize(data); } lock (String.Intern(key)) { var entity = context.SettingProperties.Where(x => x.Key == key).SingleOrDefault(); if (entity != null) { entity.StrValue = strData; Update(entity); } else { entity = new SettingProperty() { Key = key, StrValue = strData }; Create(entity); } Cache.Remove(CreateCacheKeyForThisType(key)); Cache.Remove(CreateCacheKeyForThisType(key + "_object")); } } }
protected override void FillEntitySet(NormalizedStatement entity) { base.FillEntitySet(entity); if (entity.StatementDefinition != null) { entity.StatementDefinitionData = JsonSerializationUtility.Serialize(entity.StatementDefinition); } }
protected override void FillEntityGet(WorkloadAnalysis entity) { base.FillEntityGet(entity); if (entity.RelationReplacementsData != null) { entity.RelationReplacements = JsonSerializationUtility.Deserialize <List <WorkloadAnalysisRelationReplacement> >(entity.RelationReplacementsData); } }
public VirtualEnvironment GetDetail(long environmentID) { using (var context = CreateContextFunc()) { var result = context.VirtualEnvironments.Include(x => x.VirtualEnvironmentPossibleCoveringIndices) .Include(x => x.VirtualEnvironmentStatementEvaluations).ThenInclude(x => x.ExecutionPlan) .Where(x => x.ID == environmentID).SingleOrDefault(); result.VirtualEnvironmentStatementEvaluations.ForEach(x => { x.AffectingIndices = JsonSerializationUtility.Deserialize <HashSet <long> >(x.AffectingIndicesData); x.UsedIndices = JsonSerializationUtility.Deserialize <HashSet <long> >(x.UsedIndicesData); }); return(result); } }
protected override void FillEntityGet(VirtualEnvironmentStatementEvaluation entity) { base.FillEntityGet(entity); entity.AffectingIndices = JsonSerializationUtility.Deserialize <HashSet <long> >(entity.AffectingIndicesData); entity.UsedIndices = JsonSerializationUtility.Deserialize <HashSet <long> >(entity.UsedIndicesData); }
protected override void FillEntitySet(VirtualEnvironmentStatementEvaluation entity) { base.FillEntitySet(entity); entity.AffectingIndicesData = JsonSerializationUtility.Serialize(entity.AffectingIndices); entity.UsedIndicesData = JsonSerializationUtility.Serialize(entity.UsedIndices); }
public IEnumerable <VirtualEnvironment> GetAllForWorkloadAnalysis(long workloadAnalysisID, VirtualEnvironmentType type) { using (var context = CreateContextFunc()) { var query = context.VirtualEnvironments.Where(x => x.WorkloadAnalysisID == workloadAnalysisID && x.Type == type); if (type == VirtualEnvironmentType.Indices) { query = query.Include(x => x.VirtualEnvironmentPossibleIndices); } else if (type == VirtualEnvironmentType.HPartitionings) { query = query.Include(x => x.VirtualEnvironmentPossibleHPartitionings); } var result = query.ToList(); if (type == VirtualEnvironmentType.HPartitionings) { result.SelectMany(x => x.VirtualEnvironmentPossibleHPartitionings).ToList().ForEach(x => x.PartitionStatements = JsonSerializationUtility.Deserialize <HashSet <string> >(x.PartitionStatementsData)); } return(result); } }
protected override void FillEntitySet(Workload entity) { base.FillEntitySet(entity); entity.DefinitionData = JsonSerializationUtility.Serialize(entity.Definition); }
protected override void FillEntitySet(WorkloadAnalysis entity) { base.FillEntitySet(entity); entity.RelationReplacementsData = JsonSerializationUtility.Serialize(entity.RelationReplacements); }
private static string SerializeToJson <T>(T data) { return(JsonSerializationUtility.Serialize(data)); }
protected override void FillEntityGet(PossibleIndex entity) { base.FillEntityGet(entity); entity.FilterExpressions = JsonSerializationUtility.Deserialize <PossibleIndexFilterExpressionsData>(entity.FilterExpressionsData); }
protected override void FillEntitySet(PossibleIndex entity) { base.FillEntitySet(entity); entity.FilterExpressionsData = JsonSerializationUtility.Serialize(entity.FilterExpressions); }
protected override void FillEntitySet(VirtualEnvironmentPossibleHPartitioning entity) { base.FillEntitySet(entity); entity.PartitionStatementsData = JsonSerializationUtility.Serialize(entity.PartitionStatements); }
protected override void FillEntityGet(VirtualEnvironmentPossibleHPartitioning entity) { base.FillEntityGet(entity); entity.PartitionStatements = JsonSerializationUtility.Deserialize <HashSet <string> >(entity.PartitionStatementsData); }
protected override void FillEntityGet(Workload entity) { base.FillEntityGet(entity); entity.Definition = JsonSerializationUtility.Deserialize <WorkloadDefinition>(entity.DefinitionData); }