private static IClrTypeMapping <PercolatedQuery> PercolatorInferrence(ClrTypeMappingDescriptor <PercolatedQuery> map)
        {
            var typeName = Configuration.ElasticsearchVersion <= new ElasticsearchVersion("5.0.0-alpha1") ? ".percolator" : "query";

            return(map
                   .IndexName("queries")
                   .TypeName(typeName));
        }
示例#2
0
 private static IClrTypeMapping <Project> ProjectMapping(ClrTypeMappingDescriptor <Project> m)
 {
     m.IndexName("project").IdProperty(p => p.Name);
     //*_range type only available since 5.2.0 so we ignore them when running integration tests
     if (VersionUnderTestSatisfiedBy("<5.2.0") && Configuration.RunIntegrationTests)
     {
         m.Ignore(p => p.Ranges);
     }
     return(m);
 }
示例#3
0
 private IClrTypeMapping <Specimen> GetClrMapping(ClrTypeMappingDescriptor <Specimen> mapping) =>
 mapping.IndexName(IndexName)
 .PropertyName(s => s.Id, "id")
 .PropertyName(s => s.Name, "name")
 .PropertyName(s => s.Quantity, "quantity")
 .PropertyName(s => s.InventoryItem, "inventoryItem")
 .PropertyName(s => s.Notes, "notes")
 .PropertyName(s => s.CreatedBy, "createdBy")
 .PropertyName(s => s.ModifiedBy, "modifiedBy")
 .PropertyName(s => s.DateCreated, "dateCreated")
 .PropertyName(s => s.DateModified, "dateModified");
        public static ClrTypeMappingDescriptor <T> Map <T>(this ClrTypeMappingDescriptor <T> clr, Expression <Func <T, object> > selector) where T : class
        {
            if (!(selector.Body is MemberExpression body))
            {
                body = ((UnaryExpression)selector.Body).Operand as MemberExpression;
            }

            if (body == null)
            {
                return(clr);
            }

            var name = body.Member.Name;

            PropertyInfoFactory.AddIncludedProperty <T>(name);

            return(clr);
        }
示例#5
0
        public static ClrTypeMappingDescriptor <TSource> RenameAll <TSource>(this ClrTypeMappingDescriptor <TSource> typeMappingDescriptor) where TSource : class
        {
            var typeMap = (IClrTypeMapping <TSource>)typeMappingDescriptor;

            var properties = typeof(TSource).GetProperties();

            if (typeMap.TypeName == null)
            {
                throw new Exception($"{typeof(TSource).FullName} don't have type name");
            }

            foreach (var property in properties)
            {
                var expression = GetExpressionProperty <TSource>(property);
                typeMappingDescriptor = typeMappingDescriptor.Rename(expression, $"{typeMap.TypeName}_{expression.GetMemberName(true)}");
            }

            return(typeMappingDescriptor);
        }
示例#6
0
 private IClrTypeMapping <PlantInfo> GetClrMapping(ClrTypeMappingDescriptor <PlantInfo> mapping) =>
 mapping.IndexName(IndexName)
 .PropertyName(pl => pl.Id, "id")
 .PropertyName(pl => pl.CommonName, "commonName")
 .PropertyName(pl => pl.ScientificName, "scientificName")
 .PropertyName(pl => pl.Preferred, "preferred")
 .PropertyName(pl => pl.BloomTimes, "bloomTimes")
 .PropertyName(pl => pl.MinimumBloomTime, "minBloom")
 .PropertyName(pl => pl.MaximumBloomTime, "maxBloom")
 .PropertyName(pl => pl.MinimumHeight, "minHeight")
 .PropertyName(pl => pl.MaximumHeight, "maxHeight")
 .PropertyName(pl => pl.HeightUnit, "heightUnit")
 .PropertyName(pl => pl.MinimumSpread, "minSpread")
 .PropertyName(pl => pl.MaximumSpread, "maxSpread")
 .PropertyName(pl => pl.SpreadUnit, "spreadUnit")
 .PropertyName(pl => pl.WaterTypes, "waterTypes")
 .PropertyName(pl => pl.MinimumWater, "minWater")
 .PropertyName(pl => pl.MaximumWater, "maxWater")
 .PropertyName(pl => pl.LightTypes, "lightTypes")
 .PropertyName(pl => pl.MinimumLight, "minLight")
 .PropertyName(pl => pl.MaximumLight, "maxLight")
 .PropertyName(pl => pl.StratificationStages, "stratificationStages")
 .PropertyName(pl => pl.WildlifeEffects, "wildlifeEffects")
 .PropertyName(pl => pl.SoilTypes, "soilTypes")
 .PropertyName(pl => pl.Zones, "zones")
 .PropertyName(pl => pl.MinimumZone, "minZone")
 .PropertyName(pl => pl.MaximumZone, "maxZone")
 .PropertyName(pl => pl.Visibility, "visibility")
 .PropertyName(pl => pl.CreatedBy, "createdBy")
 .PropertyName(pl => pl.ModifiedBy, "modifiedBy")
 .PropertyName(pl => pl.DateCreated, "dateCreated")
 .PropertyName(pl => pl.DateModified, "dateModified")
 .PropertyName(pl => pl.Lifeform, "lifeform")
 .PropertyName(pl => pl.Origin, "origin")
 .PropertyName(pl => pl.Taxon, "taxon")
 .PropertyName(pl => pl.User, "user")
 .PropertyName(pl => pl.PlantLocations, "plantLocations")
 .PropertyName(pl => pl.Synonyms, "synonyms");
 public static ClrTypeMappingDescriptor <T> IndexTypeNameInferrer <T>(this ClrTypeMappingDescriptor <T> clr,
                                                                      string additionalSuffix = null) where T : class
 {
     return(clr.IndexName(additionalSuffix + typeof(T).Name.ToLower().Replace("entity", "")));
 }