コード例 #1
0
        override public IEnumerable <User> GetAll()
        {
            using (var connection = GetConnection())
            {
                try
                {
                    string sql = "SELECT Id, Name FROM User;";

                    connection.Open();
                    var allUsers = new List <User>();
                    using (var command = new SqliteCommand(sql, connection))
                    {
                        command.CommandText = sql;
                        command.CommandType = CommandType.Text;
                        var reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            allUsers.Add(new User(
                                             reader.GetFieldValue <string>("Name"),
                                             reader.GetFieldValue <int>("Id")));
                        }
                    }
                    return(allUsers);
                }
                catch (Exception e)
                {
                    Console.WriteLine("!!!" + DbUtilityHelper.GetConnectionInfo(connection));
                    throw e;
                }
            }
        }
コード例 #2
0
 public TaskManager(UserManager userManager)
 {
     this.connection  = DbUtilityHelper.GetConnection();
     this.userManager = userManager;
 }
コード例 #3
0
 private static SqliteConnection GetConnection()
 {
     return(DbUtilityHelper.GetConnection());
 }
コード例 #4
0
 public SQLite3Store()
 {
     this.connection  = DbUtilityHelper.GetConnection();
     this.userManager = new UserManager();
     this.taskManager = new TaskManager(userManager);
 }
コード例 #5
0
 public UserManager()
 {
     connection = DbUtilityHelper.GetConnection();
     Console.WriteLine(connection.DataSource.ToString());
 }
コード例 #6
0
 protected SqliteConnection GetConnection()
 {
     return(DbUtilityHelper.GetConnection());
 }