public List<string> GetTableList() { var r = new List<string>(); var query = from meta in this.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) let properties = meta is EntityType ? (meta as EntityType).Properties : null select new { TableName = (meta as EntityType).Name }; query.ToList().ForEach(c => r.Add(c.TableName)); return r; } public List<string> GetFieldList(string table) { var r = new List<string>(); var query = from meta in this.MetadataWorkspace.GetItems(DataSpace.CSpace) .Where(m => m.BuiltInTypeKind == BuiltInTypeKind.EntityType) let properties = meta is EntityType ? (meta as EntityType).Properties : null where (meta as EntityType).Name == table from p in properties select new { FieldName = p.Name, DbType = p.TypeUsage.EdmType.Name }; query.ToList().ForEach(c => r.Add(c.FieldName)); return r; }
Source
No comments:
Post a Comment