//public DP_SearchRepository ToSearchRepository(SearchRepository entityPreDefinedSearch, bool withDetails) //{ // //فانکشن به یه کلاس مستقل دیگر منتقل شود // DP_SearchRepository result = new DP_SearchRepository(); // result.TargetEntityID = entityPreDefinedSearch.TableDrivedEntityID??0; // result.Title = entityPreDefinedSearch.Title; // result.EntitySearchID = entityPreDefinedSearch.EntitySearchID ?? 0; // //result.IsSimpleSearch = entityPreDefinedSearch.IsSimpleSearch; // result.ID = entityPreDefinedSearch.ID; // if (withDetails) // { // if (entityPreDefinedSearch.SearchRepository != null) // result.SearchRepository = ToSearchRepositoryDTO(entityPreDefinedSearch.SearchRepository, entityPreDefinedSearch.TableDrivedEntityID, entityPreDefinedSearch.TableDrivedEntity.Name); // //foreach (var item in entityPreDefinedSearch.PreDefinedSearchSimpleSearchColumns) // //{ // // PreDefinedSearchColumns newCol = new PreDefinedSearchColumns(); // // newCol.ColumnID = item.ColumnID ?? 0; // // newCol.EntitySearchColumnsID = item.EntitySearchColumnsID ?? 0; // // newCol.Value = item.Value; // // newCol.Operator = (CommonOperator)Enum.Parse(typeof(CommonOperator), item.Operator); // // result.SimpleColumns.Add(newCol); // //} // } // return result; //} private ProxyLibrary.LogicPhraseDTO ToLogicPhraseDTO(DataAccess.LogicPhrase logicPhrase) { ProxyLibrary.LogicPhraseDTO result = null; if (logicPhrase.SearchRepository != null) { result = ToSearchRepositoryDTO(logicPhrase.SearchRepository); } else { result = new ProxyLibrary.LogicPhraseDTO(); SetLogicPhraseDTO(logicPhrase, result); } return(result); }
private void SetLogicPhraseDTO(DataAccess.LogicPhrase logicPhrase, ProxyLibrary.LogicPhraseDTO logicPhraseDTO) { logicPhraseDTO.AndOrType = (AndOREqualType)logicPhrase.AndOrType; foreach (var dbPhrase in logicPhrase.Phrase1) { if (dbPhrase.ColumnPhrase != null) { logicPhraseDTO.Phrases.Add(ToColumnPhraseDTO(dbPhrase.ColumnPhrase)); } //else if (dbPhrase.SearchRepository != null) // logicPhraseDTO.Phrases.Add(ToSearchRepositoryDTO(dbPhrase.SearchRepository)); else if (dbPhrase.LogicPhrase != null) { logicPhraseDTO.Phrases.Add(ToLogicPhraseDTO(dbPhrase.LogicPhrase)); } } }
private void SetLogicPhrase(MyProjectEntities projectContext, DataAccess.LogicPhrase dbLogicPhrase, ProxyLibrary.LogicPhraseDTO logicPhrase) { dbLogicPhrase.AndOrType = (short)logicPhrase.AndOrType; foreach (var phrase in logicPhrase.Phrases) { DataAccess.Phrase dbPhrase = null; if (phrase is SearchProperty) { dbPhrase = ToColumnPhrase(projectContext, phrase as SearchProperty).Item2; } else if (phrase is DP_SearchRepository) { dbPhrase = CreateSearchRepository(projectContext, phrase as DP_SearchRepository); } else if (phrase is ProxyLibrary.LogicPhraseDTO) { dbPhrase = ToLogicPhrase(projectContext, phrase as ProxyLibrary.LogicPhraseDTO).Item2; } dbPhrase.LogicPhrase1 = dbLogicPhrase; } }