Append properties in NEST

Hi ,

I have the below code , to append the properites to PropertiesDescriptor, But the last property is getting replaced by the new one, Can you please help me with this .

public Func<MappingsDescriptor, IPromise> GetMappingsDescriptorr = map => map.Map(t =>
{
var properites = typeof(T).GetProperties();
t.Properties(p =>
{
foreach (var property in properites)
{
if (property.MemberType == System.Reflection.MemberTypes.Property)
{
var typeOfProperty = property.PropertyType;
if (typeOfProperty == typeof(string))
{
p.Keyword(f => f.Name(n => property.Name));
}
else if (typeOfProperty == typeof(Dslr))
{
p.Object(f => f.Name(n => property.Name));
}
else if (typeOfProperty == typeof(DateTime))
{
p.Date(f => f.Name(n => property.Name));
}
}
}
return p;
});
return t;
});

I trying create mapping dynamically based on the available properites in a class, But when i try to add second properites the first one is getting replaced by the second.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.