public List<Column> GetPKList(DataTable dt) { List<Column> list = new List<Column>(); Column c = null; if (dt.PrimaryKey.Length > 0) { list = new List<Column>(); foreach (DataColumn dc in dt.PrimaryKey) { c = new Column(dc); list.Add(c); } } return list; }
private List<Column> GetColumnList(DataTable dt) { List<Column> list = new List<Column>(); List<Column> listPk = new List<Column>(); if (dt.PrimaryKey.Length > 0) { listPk.AddRange(dt.PrimaryKey.Select(column => new Column(column))); } Column c = null; foreach (DataColumn dc in dt.Columns) { c = new Column(dc); if (listPk.Where(m => m.ColumnName == c.ColumnName).FirstOrDefault() != null) { c.IsPK = true; } list.Add(c); } return list; }