public T GetByNameAndCultureAndScopeWithHierarchies( string name, string cultureName, string dictionaryScopeName ) { if (string.IsNullOrEmpty(name)) { throw new ArgumentException(EmptyArgumentMessage, nameof(name)); } if (string.IsNullOrEmpty(dictionaryScopeName)) { throw new ArgumentException(EmptyArgumentMessage, nameof(dictionaryScopeName)); } try { var session = GetSession(); DictionaryScopeEntity dictionaryScope = null; CultureEntity culture = null; CultureHierarchyEntity cultureHierarchy = null; CultureEntity childCulture = null; var query = session.QueryOver <T>() .Where(x => x.Name == name) .Fetch(SelectMode.Fetch, x => x.Culture) .Fetch(SelectMode.Fetch, x => x.DictionaryScope) .JoinAlias(x => x.DictionaryScope, () => dictionaryScope) .JoinAlias(x => x.Culture, () => culture) .Where(x => dictionaryScope.Name == dictionaryScopeName) .JoinAlias(x => culture.ChildCultureHierarchy, () => cultureHierarchy) .JoinAlias(x => cultureHierarchy.Culture, () => childCulture) .Where(x => childCulture.Name == cultureName) .OrderBy(() => cultureHierarchy.LevelProperty).Asc .Take(4).List(); return(query.FirstOrDefault()); } catch (Exception ex) { throw new DataException("GetByNameAndCultureAndScopeWithHierarchies operation failed", ex); } }
public virtual int AddCultureHierarchy( CultureEntity culture, CultureEntity parentCulture, byte levelProperty ) { using (var session = GetSession()) { var cultureHierarchyRepository = new CultureHierarchyRepository(session); var cultureHierarchy = new CultureHierarchyEntity { Culture = culture, ParentCulture = parentCulture, LevelProperty = levelProperty, }; var result = (int)cultureHierarchyRepository.Create(cultureHierarchy); return(result); } }