private void CreateDocument(ParentTestClass document, IndexName index, ElasticClient client) { //var index = new IndexName { Name = "TestName", Type = typeof(ParentTestClass) }; var descriptor = new CreateIndexDescriptor(index); var t = new Test(); var t1 = new Test1(); Func <Func <TypeMappingDescriptor <ParentTestClass>, ITypeMapping>, CreateIndexDescriptor> seed = f => { descriptor = descriptor.Mappings(m => m.Map <ParentTestClass>(f)); return(descriptor); }; var list = new List <Test> { t, t1 }; var res = list.Aggregate(seed, (x, next) => { //throw new NotImplementedException(); var returnRes = new Func <Func <TypeMappingDescriptor <ParentTestClass>, ITypeMapping>, CreateIndexDescriptor> ( pr => { x(next.F(pr)); return(descriptor); throw new NotImplementedException(); }); return(returnRes); }); var ex = res(new Func <TypeMappingDescriptor <ParentTestClass>, ITypeMapping>(q => null)); client.CreateIndex(descriptor); var documentType = document.GetType(); //var client = this._clientFactory.GetClient(); var documentPath = new DocumentPath <ParentTestClass>(document); //var index = this.GetIndex(document, client); documentPath.Type(documentType); documentPath.Index(index); var createRequest = new CreateRequest <ParentTestClass>(documentPath); var response = client.Create(createRequest); }