Example #1
0
        public static List <TblData> GetAll(string Query)
        {
            List <TblData> ListTep = new List <TblData>();
            SqlCommand     cmd     = null;
            SqlDataReader  SDR     = null;
            DBCon          conn    = new DBCon();

            try
            {
                cmd = new SqlCommand(Query, conn.Con);
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    TblData formmdata = new TblData();
                    JObject jObject   = new JObject();
                    for (int i = 0; i < SDR.FieldCount; i++)
                    {
                        string fieldName = SDR.GetName(i);
                        var    test      = SDR.GetValue(i);
                        jObject.Add(fieldName, GetValues(SDR, i));
                    }
                    formmdata.Jobj = jObject;
                    ListTep.Add(formmdata);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); conn.Close(); }
            return(ListTep);
        }
Example #2
0
        public static List <TblData> GetAll(string PName, JObject Params)
        {
            List <TblData> ListTep = new List <TblData>();
            SqlCommand     cmd     = null;
            SqlDataReader  SDR     = null;
            DBCon          conn    = new DBCon();

            try
            {
                cmd             = new SqlCommand(PName, conn.Con);
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                IList <string> keys = Params.Properties().Select(p => p.Name).ToList();
                for (int i = 0; i < keys.Count; i++)
                {
                    cmd.Parameters.AddWithValue(keys[i], Params[keys[i]].ToString());
                }
                SDR = cmd.ExecuteReader();
                while (SDR.Read())
                {
                    TblData formmdata = new TblData();
                    JObject jObject   = new JObject();
                    for (int i = 0; i < SDR.FieldCount; i++)
                    {
                        string fieldName = SDR.GetName(i);
                        var    test      = SDR.GetValue(i);
                        jObject.Add(fieldName, GetValues(SDR, i));
                    }
                    formmdata.Jobj = jObject;
                    ListTep.Add(formmdata);
                }
            }
            catch (Exception e) { e.ToString(); }
            finally { cmd.Dispose(); SDR.Close(); conn.Close(); }
            return(ListTep);
        }