public virtual bool ValidateColumnsHeader(IEnumerable <Cell> cells) { try { //get properties of entity var properties = typeof(TEntity).GetProperties(); //loop through each cell in header row for (int i = 0; i < cells.Count(); i++) { //get cell reference Cell cell = cells.ElementAt(i); //get column header text string header = (string)GetCellValue(cell); //check if header name is consider a property in entity if (!properties.Any(x => x.Name.Equals(header, StringComparison.OrdinalIgnoreCase))) { //check in reference entity properties var dependences = EntityDependences.Where(x => x.Value.GetProperties().Any(y => y.Name.Equals(header, StringComparison.OrdinalIgnoreCase))); //if not exist then validation process is fail if (!dependences.Any()) { return(false); } else { //header name is consider a property of child reference of the entity //built HeaderEntityReferences object if (HeaderEntityReferences == null) { HeaderEntityReferences = new List <HeaderEntityReference>(); } //get dependence reference object that contain (Reference Type & Foreign Key Property name) var dep = dependences.ElementAt(0); //check if headerEntityReference which has same referece type is inserted before var her = HeaderEntityReferences.SingleOrDefault(x => x.ReferenceType == dep.Value); if (her == null) { //create list of headersInfo that hold information of header index and header name and corresponding property name in child reference entity List <HeaderInfo> headersInfo = new List <HeaderInfo>(); headersInfo.Add(new HeaderInfo() { HeaderIndex = i, HeaderName = header, EntityPropertyName = header }); // create new HeaderEntityReferences her = new HeaderEntityReference() { Headers = headersInfo, ReferenceType = dep.Value, ForeignKeyProperty = dep.Key }; HeaderEntityReferences.Add(her); } else { //add only header infomartion her.Headers.Add(new HeaderInfo() { HeaderIndex = i, HeaderName = header, EntityPropertyName = header }); } } } } return(true); } catch (Exception ex) { throw ex; } }