简体   繁体   English

如何制作数据访问层C#

[英]how to make data access layer C#

Ive been given the task of making a data access layer to connect to a sqlite database for a basic c# application. 已经完成了使数据访问层连接到基本c#应用程序的sqlite数据库的任务。 From what ive been told, I need to have 2 class files, 1 that holds the methods and one that connects to the database. 就我所知,我需要有2个类文件,其中1个包含方法,而1个连接到数据库。 However im not to sure where to start, any help would be appreciated. 但是我不确定从哪里开始,我们将不胜感激。

Thanks in advance Brian 在此先感谢Brian

More - 更多 -

From the links that you guys have provided it would appear that a data access layer is just a single class file with basic methods such as createDB, AddToDB, GetFromDB and other classes from the project just reference this class file and call those methods. 从你们提供的链接中可以看出,数据访问层只是一个具有基本方法(例如createDB,AddToDB,GetFromDB和项目中其他类)的类文件,仅引用该类文件并调用这些方法。

Is my assumpt above correct? 我的上述假设正确吗? if not i'd like your opinions on this :) 如果不是这样的话,我希望您对此有意见:)

I googled "Data Access Layer C#" and "C# sqlite dal" to get some helpful links: 我在“数据访问层C#”和“ C#sqlite dal”上进行了搜索,以获取一些有用的链接:
Tutorial 1: Creating a Data Access Layer - MSDN - Microsoft 教程1:创建数据访问层-MSDN-Microsoft
Easy Data Access Layer 简易数据访问层
A Basic SQLite DAL class in C# C#中的基本SQLite DAL类

When you create your DAL or before, you probaly want to write some Unit test for your DAL. 在创建DAL或之前,您可能想为DAL编写一些单元测试。 Here is an article describe this proccess. 这是一篇描述此过程的文章。 how-to write unit tests for you Data Access Layer using in-memory database . 如何使用内存数据库为您的数据访问层编写单元测试

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM