Exemplo n.º 1
0
 public TsIndexField()
 {
     TsDbField = new TsDbField();
 }
        public List<TsDbField> GetTsDbFields(int templateBatchId)
        {
            var tsDbFields = new List<TsDbField>();
            var strSql = string.Format(@"SELECT FieldID, FieldName, Options FROM Index{0} ORDER BY FieldID", templateBatchId);
            try
            {
                using (var myConn = new SqlConnection(ConnectionString))
                {
                    using (var cmd = new SqlCommand(strSql, myConn))
                    {
                        myConn.Open();
                        using (var myDataReader = cmd.ExecuteReader())
                        {
                            if (myDataReader.HasRows)
                            {
                                while (myDataReader.Read())
                                {
                                    var tsDbField = new TsDbField
                                    {
                                        FieldId = Convert.ToInt32(myDataReader[0]),
                                        FieldName = myDataReader[1].ToString(),
                                        Options = myDataReader[2].ToString()
                                    };

                                    tsDbFields.Add(tsDbField);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //throw;
            }
            return tsDbFields;
        }