【发布时间】:2017-09-20 01:29:37
【问题描述】:
我是编程新手,我正在尝试使用 WPF 创建一个简单的食堂/商店管理应用程序(这将是我构建的第一个真实世界应用程序)。我认为我应该克服的第一步是创建一个处理与数据库相关的所有方面的类。目前我正在使用 SQLite,但希望最终能够包括对许多不同数据库的支持。简而言之,我想就我在创建 IDatabase 接口然后在 Database 类中实现它所采取的路径是否有意义或者是否有更好的方法来提出意见。谢谢!我在下面包含了到目前为止我编写的代码。
public interface IDatabase
{
bool IsConnected { get; }
bool Connect(string connectionString);
void Disconnect();
List<Account> SearchAccounts(Account account);
Account CreateAccount(Account account);
Account GetAccount(int accountId);
void DeleteAccount(int accountId);
List<PersonCategory> SearchPersonCategories(PersonCategory personCategory);
void AddPersonCategory(PersonCategory personCategory);
PersonCategory GetPersonCategory(int CategoryId);
List<Person> SearchPeople(Person person);
Person CreatePerson(Person person);
Person GetPerson(int personId);
void DeletePerson();
List<Transaction> SearchTransactions(Transaction transaction);
Transaction GetTransaction(int transactionId);
void AddTransaction(Transaction tansaction);
List<Log> SearchLogs(Log log);
Log GetLog(int logId);
void AddLog(Log log);
List<ProductCategory> SearchProductCategories(ProductCategory productCategory);
void AddProductCategory(ProductCategory productCategory);
ProductCategory GetProductCategory(int categoryId);
void DeleteProductCategory(int categoryId);
List<Product> SearchProducts(Product product);
void AddProduct(Product product);
Product GetProduct(int productId);
void DeleteProduct(int productId);
}
【问题讨论】:
-
感谢您的链接!看起来这就是每个人都指向我的地方。我想在我开始这个项目之前我需要学习 EF。
-
我目前正在查看使用 SQLite 的 EF 教程,在我看来,没有办法使用设计器等自动化工具......除非你使用我不是的 SQL 服务器。这是真的吗?
-
微软多年后学到的是,设计师很糟糕,因为代码生成很糟糕。最初的学习曲线可能会稍微陡峭,但一旦掌握了窍门,它实际上会容易得多。
标签: c# database class interface