//public IEnumerable<LocationPropertyData> GetByLocationType(int LocationTypeId)
        //{
        //    CurrentCollection.Clear();
        //    var MySql = new Sql();
        //    MySql.Select("*").From<LocationPropertyData>().Where("LocationTypeId = @0", LocationTypeId);
        //    CurrentCollection.AddRange(Repositories.ThisDb.Fetch<LocationPropertyData>(MySql).ToList());
        //    FillChildren();

        //    return CurrentCollection;
        //}

        public IEnumerable <LocationPropertyData> GetByLocation(Guid LocationKey)
        {
            List <LocationPropertyData>           Result = new List <LocationPropertyData>();
            IEnumerable <LocationPropertyDataDto> dtoResults;

            CurrentCollection.Clear();

            var sql = new Sql();

            sql.Select("*").From <LocationPropertyDataDto>().Where("LocationKey = @0", LocationKey);

            dtoResults = Repositories.ThisDb.Fetch <LocationPropertyDataDto>(sql).ToList();

            var converter = new DtoConverter();

            foreach (var result in dtoResults)
            {
                Result.Add(converter.ToLocationPropertyDataEntity(result));
            }

            CurrentCollection.AddRange(Result);
            //FillChildren();

            return(CurrentCollection);
        }
        protected override IEnumerable <LocationPropertyData> PerformGetAll(params Guid[] Keys)
        {
            List <LocationPropertyData>           Result = new List <LocationPropertyData>();
            IEnumerable <LocationPropertyDataDto> dtoResults;

            if (Keys.Any())
            {
                foreach (var key in Keys)
                {
                    Result.Add(Get(key));
                }
            }
            else
            {
                var sql = new Sql();
                sql.Select("*").From <LocationPropertyDataDto>();

                dtoResults = Repositories.ThisDb.Fetch <LocationPropertyDataDto>(sql).ToList();

                var converter = new DtoConverter();
                foreach (var result in dtoResults)
                {
                    Result.Add(converter.ToLocationPropertyDataEntity(result));
                }
            }

            return(Result);
        }
        public LocationPropertyData GetByAlias(string PropertyAlias, Guid LocationKey)
        {
            CurrentCollection.Clear();
            var sql = new Sql();

            sql
            .Select("*")
            .From <LocationPropertyDataDto>()
            .InnerJoin <LocationTypePropertyDto>()
            .On <LocationPropertyDataDto, LocationTypePropertyDto>(left => left.LocationTypePropertyKey, right => right.Key)
            .Where <LocationTypePropertyDto>(n => n.Alias == PropertyAlias)
            .Where <LocationPropertyDataDto>(n => n.LocationKey == LocationKey);

            var dtoResult = Repositories.ThisDb.Fetch <LocationPropertyDataDto>(sql).FirstOrDefault();

            if (dtoResult == null)
            {
                return(null);
            }

            var converter = new DtoConverter();
            var entity    = converter.ToLocationPropertyDataEntity(dtoResult);

            return(entity);
            //FillChildren();

            //return CurrentCollection[0];
        }
        protected override LocationPropertyData PerformGet(Guid Key)
        {
            var sql = new Sql();

            sql
            .Select("*")
            .From <LocationPropertyDataDto>()
            .Where <LocationPropertyDataDto>(n => n.Key == Key);

            var dtoResult = Repositories.ThisDb.Fetch <LocationPropertyDataDto>(sql).FirstOrDefault();

            if (dtoResult == null)
            {
                return(null);
            }

            var converter = new DtoConverter();
            var entity    = converter.ToLocationPropertyDataEntity(dtoResult);

            return(entity);
        }