我为产品类型创建索引。产品内部具有指南命名对象。 Guide是基类和继承类,例如Guide1 Guide2 Guide3 vs ..
我再次创建产品类后创建Product对象并索引弹性,但这一次是Product中的Guide1类。
我是按产品嵌套获取的,而不是将Guide1强制转换为产品。
public class Product{
public string Name{get;set;}
public Guide Guide{get;set;}
}
public class Guide{
public int ID{get;set;}
public string Title{get;set;}
}
public class Guide1 : Guide{
public double Price{get;set;}
}
Product p1 elasticContext.Get<Product>(1, idx => idx.Index("products"));
指南1强制转换为指南,但我无法访问Guide1属性
答案 0 :(得分:0)
在嵌套连接设置中调用记录类型时,完整类型会返回
new ConnectionSettings(node, sourceSerializer: (b, s) => new JsonNetSerializer(b, s, () => new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All }));