# NEST: inference derived class into base class using condition with automapping

**URL:** <https://discuss.elastic.co/t/nest-inference-derived-class-into-base-class-using-condition-with-automapping/313348>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [August 31, 2022, 10:48am UTC](https://discuss.elastic.co/t/nest-inference-derived-class-into-base-class-using-condition-with-automapping/313348 "2022-08-31T10:48:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alex83](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/alex83/32/98091_2.png) [@Alex83](https://discuss.elastic.co/u/Alex83)\
**Post date:** [August 31, 2022, 10:48am UTC](https://discuss.elastic.co/t/nest-inference-derived-class-into-base-class-using-condition-with-automapping/313348/1 "2022-08-31T10:48:47Z")

</div>

Hi, i have in my model an object type "Order" that it contains a property of type "Customer".  
Customer is a base class with some tipically fields ( **customerType** , name, surname, etc.) and its a base class because customer can be type "PrivateCustomer" or "BusinessCustomer" (derived class from customer) using a inherited property " **customerType**" .  
Now, i'm trying to use automapping objects in NEST to get a derived class when i put object in elastichsearch, but NEST retrieve only properties from base class and not from derived class.  
How can i do to get derived class from order object using property "customerType"?  
Thanks a lot

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 28, 2022, 10:49am UTC](https://discuss.elastic.co/t/nest-inference-derived-class-into-base-class-using-condition-with-automapping/313348/2 "2022-09-28T10:49:32Z")

</div>

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