16
DATABASES IN .NET Victor Haydin Eleks Software Ltd.

Databases in .NET

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Databases in .NET

DATABASES IN .NETVictor Haydin

Eleks Software Ltd.

Page 2: Databases in .NET

Data and Databases

Computer science is not about computing.

Its about

data processing.

Page 3: Databases in .NET

Database engines

Page 4: Databases in .NET

Application/DB interaction

Frontend Server

Database Server

Data Access Layer

Business Logic Layer

Presentation Layer

Database drivers

Page 5: Databases in .NET

Entity Framework

LINQ2SQL

NHibernate

Others

System.Data.SqlClient

ADO.Net

Page 6: Databases in .NET

System.Data.SqlClient

System.Data.SqlClient – set of classes for low-level operations with MS SQL Server.

SqlConnection

SqlCommand

SqlDataReader

Page 7: Databases in .NET

DEMOSQL Client

Page 8: Databases in .NET

Transactions & Isolation levels

Serializable

Repeatable Reads

Read Commited

Read Uncommited

Page 9: Databases in .NET

Isolation levels

Isolation level

Dirty reads

Non-repeatable reads

Phantoms

Read Uncommitted

X X XRead Committed - X XRepeatable Read - - XSerializable - - -

Isolation level

Write Lock

Read LockRange Lock

Read Uncommitted

- - -Read Committed V - -Repeatable Read V V -Serializable V V V

Read Issues Locks

Page 10: Databases in .NET

ORM

Page 11: Databases in .NET

Why ORM?

Relational Model:TablesRowsColumnsPrimary/Foreign keys?

Object Model:CollectionsObjectsPropertiesCompositionInheritance

Page 12: Databases in .NET

ORM Frameworks

Entity Framework

LINQ2SQL

NHibernate

DevExpress XPO

Subsonic

ObjectMapper.Net

Self-made

Page 13: Databases in .NET

ADO.Net Entity Framework

Design approaches:• Database First• Model First• Code First

Entity Data Model:• Mapping• Entities• Relationships• Schema Definition

Language

Querying Data:• eSQL• LINQ to Entities• Native SQL

Inheritance:• Table per hierarchy• Table per type• Table per concrete

class

Page 14: Databases in .NET

DEMOEntity Framework

Page 15: Databases in .NET

Canonical FunctionsCanonical functions

Aggregate functions Avg, BigCount, Count, Max, Min, StDev, StDevP, Sum, Var, VarP

Math functions Abs, Ceiling, Floor, Power, Round, Truncate

String functions Concat, Contains, EndsWith, IndexOf, Left, Length, LTrim, Replace, Reverse, Right, RTrim, Substring, StartsWith, ToLower, ToUpper, Trim

Date and Time functions AddMicroseconds, AddMilliseconds, AddSeconds, AddMinutes, AddHours, AddNanoseconds, AddDays, AddYears, CreateDateTime, AddMonths, CreateDateTimeOffset, CreateTime, CurrentDateTime, CurrentDateTimeOffset, CurrentUtcDateTime, Day, DayOfYear, DiffNanoseconds, DiffMilliseconds, DiffMicroseconds, DiffSeconds, DiffMinutes, DiffHours, DiffDays, DiffMonths, DiffYears, GetTotalOffsetMinutes, Hour, Millisecond, Minute, Month, Second, Truncate, Year

Bitwise functions BitWiseAnd, BitWiseNot, BitWiseOr, BitWiseXor

Other functions NewGuid

Page 16: Databases in .NET

Q&A