Beispiel #1
0
        public static List <T> ExecuteQuery <T>(string sql, object[] ParamsList = null) where T : new()
        {
            List <SQLiteParameter> list = GetPara(sql, ParamsList);
            DataTable dt = Sqlite.ExecuteQuery(sql, list != null ? list.ToArray() : null);

            return(dt.Rows.Count > 0 ? ExcuteInfo <T> .TableToList(dt) : new List <T>());
        }
Beispiel #2
0
 public static List <T> Get <T>(string sqlWhere, object[] ParamsList = null) where T : new()
 {
     try
     {
         Type = typeof(T);
         string        displayName = Type.GetCustomAttribute <DisplayNameAttribute>().DisplayName;
         StringBuilder Sqlsb       = new StringBuilder();
         Sqlsb.Append("select * from ").Append(displayName);
         if (!string.IsNullOrEmpty(sqlWhere))
         {
             Sqlsb.Append(" where ").Append(sqlWhere);
         }
         List <SQLiteParameter> list = GetPara(Sqlsb.ToString(), ParamsList);
         DataTable dt = Sqlite.ExecuteQuery(Sqlsb.ToString(), list != null ? list.ToArray() : null);
         return(dt.Rows.Count > 0 ? ExcuteInfo <T> .TableToList(dt) : new List <T>());
     }
     catch (Exception e)
     {
         return(new List <T>());
     }
 }