public static AccountType FindOrCreate(int category, string AccountTypeName) { var accountType = new AccountType { Category = AccountCategory.Find(category), Name = AccountTypeName }; All.Add(accountType); return(accountType); }
public static AccountType[] Load(SqlConnection connection) { var list = new List <AccountType>(); var query = new SqlCommand("select id, name, account_category_id from account_type", connection); var reader = query.ExecuteReader(System.Data.CommandBehavior.SingleResult); while (reader.Read()) { list.Add(new AccountType { Id = reader.GetFieldValue <int>(0), Name = reader.GetFieldValue <string>(1), Category = AccountCategory.Find(reader.GetFieldValue <int>(2)) }); } reader.Close(); All.AddRange(list); return(All.ToArray()); }