| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Data access is a computer program that simply provides access to data stored in a consistent repository, an example of an entity-relationship database to this consistent repository.
Object-Relational Mapping (ORM) is a technique that allows you to query and manipulate data from a database using the Object-oriented paradigm. It acts as a bridge between the database and the application. It is a structure that performs all database operations without the need for the application to access the database directly, by converting the tables in the database to classes, columns to properties, and records to objects.
string sql = "SELECT FirstName FROM Accounts WHERE Id = 7"; DbCommand cmd = new DbCommand(connection, sql); Result result = cmd.Execute(); string firstName = result[0]["FirstName"];
Account user = repository.GetAccount(7); string name= user.FirstName;
Entity Framework is an open-source ORM framework for .NET applications supported by Microsoft. It enables developers to work with data using objects of domain specific classes without focusing on the underlying database tables and columns where this data is stored. With the Entity Framework, developers can work at a higher level of abstraction when they deal with data, and can create and maintain data-oriented applications with less code compared with traditional applications.
In this approach, the priority is on the database. First, the database is created, then the coding side is started.
Bu yaklaşımda design işlemlerinden çok kod yazma ön plandadır. Veritabanı işlemleri design işlemleri olarak değilde kod yazarak gerçekleştirilir. Geliştirici veritabanıyla ilgili tüm işlemleri kodlayarak oluşturur. Bu yaklaşımda hakimiyet tamamen sizdedir.
If you don't have a database, you can create a model directly from visual studio. In order to introduce the changes we have made here to sql, we need to click generate database from.
Dapper is a simple object mapper for .NET and owns the title of King of Micro ORM in terms of speed and is virtually as fast as using a raw ADO.NET data reader. An ORM is an Object Relational Mapper, which is responsible for mapping between database and programming language.
It is a three-step process.
SQL commands can be used easily with Dapper.
string sql = "INSERT INTO Customers (CustomerName) Values (@CustomerName);";
var affectedRows = connection.Execute(sql, new {CustomerName = "Mark"});
Console.WriteLine(affectedRows);
In addition, stored procedures and dynamically using parameters are also very functional.
if (db.State==ConnectionState.Closed)
{
db.Open();
//the parameters of stored procedure and ones inside param have to be same
DynamicParameters param = new DynamicParameters();
param.Add("@contactid", contactId);
param.Add("@name", txtName.Text.Trim());
param.Add("number",txtNumber.Text.Trim());
db.Execute("up_ContactAddOrEdit",param,commandType:CommandType.StoredProcedure);
if (contactId==0)
{
MessageBox.Show("Saved Succesfully");
}
else
{
MessageBox.Show("Updated Succesfully");
}
GetAllContacts();
Eraser(txtName, txtNumber);
}
| Back | FazBrowse Home | New Git URL |