public static List <ColumnProjection> GetColumnProjections(string entityName, List <string> includingPath) { var entity = MetadataRepository.Entities.Single(e => e.PhysicalName == entityName); GridView gridView = new GridView(); ODataObjectSpace objSpace = new ODataObjectSpace(); IEdmEntityType entityType = objSpace.GetTypeDefinition(entityName); string detailLayout = string.Empty; var defaultLayoutXml = GetDefaultLayout(entityName, ref detailLayout); gridView.RestoreLayoutFromString(defaultLayoutXml); var projections = gridView.Columns.Cast <GridColumn>() .Where(column => !string.IsNullOrEmpty(column.FieldName) && entityType.FindProperty(column.FieldName) != null) .Select(column => new ColumnProjection(column.FieldName, entity)).ToList(); gridView.Dispose(); gridView = null; var keyFeildName = entityType.Key().First().Name; ColumnProjection keyColumnProjection = new ColumnProjection(keyFeildName, entity); if (!projections.Any(p => p.PropertyPath == keyFeildName)) { projections.Add(keyColumnProjection); } if (includingPath != null) { foreach (var includItem in includingPath) { ColumnProjection includColumnProjection = new ColumnProjection(includItem, entity); if (!projections.Contains(includColumnProjection)) { projections.Add(includColumnProjection); } } } return(projections); }