public List <Tag> GetAllTags() { List <Tag> tags = new List <Tag>(); using (var cn = new SqlConnection(_connectiionString)) { var cmd = new SqlCommand(); cmd.Connection = cn; cmd.CommandText = @"SELECT * FROM Tag"; cmd.Connection = cn; cn.Open(); using (var dr = cmd.ExecuteReader()) { while (dr.Read()) { ToonSaloon.Models.Tag newTag = ConvertReaderToTag(dr); tags.Add(newTag); } } } return(tags); }
private Tag ConvertReaderToTag(SqlDataReader dr) { ToonSaloon.Models.Tag newTag = new ToonSaloon.Models.Tag { Id = (int)dr["TagId"], Name = dr["Name"].ToString() }; return(newTag); }