Introduction To .NET Core 1.0

Introduction To .NET Core 1.0

Introduction to .NET Florin Olariu Alexandru Ioan Cuza, University of Iai Department of Computer Science Agenda NET Framework C# access modifiers and other common types Unit testing shortcut to expert level

Entity Framework Core part1 NET Framework C# access modifiers and other common types NET Framework C# access modifiers and other common types What is an access modifier? How many access modifiers exist in C#?

Other common types NET Framework C# access modifiers and other common types What is an access modifier? NET Framework C# access modifiers and other common types What is an access modifier?

An access modifier is a keyword used to specify the accessibility of a member or a type. NET Framework C# access modifiers and other common types How many access modifiers exists in C#? NET Framework C# access modifiers and other common types How many access modifiers exists in C#?

In C# we have four access modifiers public protected internal private

NET Framework C# access modifiers and other common types How many access modifiers exists in C#? In C# we have four access modifiers public protected

internal private NET Framework C# access modifiers and other common types How many access modifiers exists in C#?

In C# we have four access modifiers public => there is no restriction in regards with accesibility public protected internal private NET Framework C# access

modifiers and other common types How many access modifiers exists in C#? In C# we have four access modifiers public protected

internal private NET Framework C# access modifiers and other common types How many access modifiers exists in C#? In C# we have four access modifiers

protected => access is limited to e containing class or types deriv from the containing class public protected internal

private NET Framework C# access modifiers and other common types How many access modifiers exists in C#? In C# we have four access modifiers public

protected internal private NET Framework C# access modifiers and other common types How many access modifiers exists in C#?

In C# we have four access modifiers public protected internal

private internal => access is limited to the current assembly NET Framework C# access modifiers and other common types How many access modifiers exists in C#? In C# we have four access modifiers

public protected internal private NET Framework C# access modifiers and other common types

How many access modifiers exists in C#? In C# we have four access modifiers public protected

internal private private => access is limited to the containing type NET Framework C# access modifiers and other common types Other common types NET Framework C# access

modifiers and other common types Other common types readonly vs const sealed virtual

NET Framework C# access modifiers and other common types Other common types readonly vs const sealed virtual

NET Framework C# access modifiers and other common types Other common types readonly vs const sealed readonly

virtual const NET Framework C# access modifiers and other common types Other common types readonly vs const

sealed readonly virtual Can be initialized: at declaration or in a constructor const NET Framework C# access modifiers and other common types

Other common types readonly vs const sealed readonly const virtual Can be initialized: at declaration

Can be initialized only at the declaration or in a constructor NET Framework C# access modifiers and other common types Other common types readonly vs const

sealed readonly const virtual Can be initialized: at declaration Can be initialized only at the declaration or in a constructor

Can be used only by fields NET Framework C# access modifiers and other common types Other common types readonly vs const sealed readonly

const virtual Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields Can be used only by fields

NET Framework C# access modifiers and other common types Other common types readonly vs const sealed readonly const

virtual Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields Can be used only by fields If is initialized via constructor can have different values

NET Framework C# access modifiers and other common types Other common types readonly vs const sealed readonly const

virtual Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields Can be used only by fields If is initialized via constructor can Is a compile-time constant

have different values NET Framework C# access modifiers and other common types Other common types readonly vs const sealed readonly

const virtual Can be initialized: at declaration or in a constructor Can be initialized only a the declaration Can be used only by fields Can be used only by fields

If is initialized via constructor can Is a compile-time constant have different values NET Framework C# access modifiers and other common types Other common types readonly vs const sealed

virtual NET Framework C# access modifiers and other common types Other common types readonly vs const sealed

virtual Can be used for classes and methods NET Framework C# access modifiers and other common types Other common types lasses => prevents other classe to inherit from it. thods => prevents from overrid virtual methods.

readonly vs const sealed virtual NET Framework C# access modifiers and other common types

Other common types lasses => prevents other classe to inherit from it. thods => prevents from overrid virtual methods. readonly vs const sealed

virtual NET Framework C# access modifiers and other common types Other common types readonly vs const sealed

virtual NET Framework C# access modifiers and other common types Other common types readonly vs const

sealed virtual t is used for: methods, propertie indexer and events. NET Framework C# access modifiers and other common types Other common types

readonly vs const sealed virtual t is used for: methods, propertie indexer and events. This allows us to override the behavior in a derived class. Unit testing shortcut to expert

level Unit testing shortcut to expert level Why unit testing? Benefits of unit tests What is a unit test?

Unit test life cycle What makes a good unit test? Best practices 2/28/20 TITLE PRESENTATION Why unit testing?

2/28/20 TITLE PRESENTATION Why unit testing? 2/28/20 TITLE PRESENTATION Why unit testing? 2/28/20 TITLE PRESENTATION Why unit testing?

Benefits of unit testing Find defects early Prevent regressions Provide living documentation (source code) Automate testing efforts

2/28/20 TITLE PRESENTATION Why unit testing? Benefits Find defects early Prevent regressions

Provide living documentation (source code) Automate testing efforts Requires tests to be as complete as possible and to be run as early and often as possible TITLE PRESENTATION What is a Unit Test?

TITLE PRESENTATION What is a Unit Test? Definition 1 TITLE PRESENTATION What is a Unit Test? Definition 1

A unit test is a piece of code (usually a method) that invoke another piece of code and checks the correctness of some assumptions afterwards. The art of unit testing 2/28/20 TITLE PRESENTATION What is a Unit Test? Definition 2

TITLE PRESENTATION What is a Unit Test? Definition 2 Essentially, a unit test is a method that instantiates a small portion of our application and verifies its behavior independently from other parts. TITLE PRESENTATION Unit test representation

Assert Act Unit Test (code) No human interaction! Code under Test TITLE PRESENTATION Unit test example

TITLE PRESENTATION What Makes a Good Unit Test? 2/28/20 TITLE PRESENTATION What Makes a Good Unit Test? Easy to write 2/28/20 TITLE PRESENTATION What Makes a Good Unit Test?

Easy to write Readable 2/28/20 TITLE PRESENTATION What Makes a Good Unit Test? Easy to write

Readable Reliable 2/28/20 TITLE PRESENTATION What Makes a Good Unit Test? Easy to write

Readable Reliable Fast 2/28/20 TITLE PRESENTATION Best practices

A test should be: TITLE PRESENTATION Best practices A test should be: Isolated TITLE PRESENTATION

Best practices A test should be: Isolated Test Only One Condition at a Time TITLE PRESENTATION Best practices

A test should be: Isolated Test Only One Condition at a Time Repeatable TITLE PRESENTATION

Best practices A test should be: Isolated Test Only One Condition at a Time Repeatable

Thorough Mock external references TITLE PRESENTATION Unit test life cycle TITLE PRESENTATION Unit test life cycle

TITLE PRESENTATION Unit test life cycle TITLE PRESENTATION Entity Framework Core part1 Entity Framework Core part1 Introduction in Entity Framework Entity Framework code first

Conventions Attributes Fluent API Creating models with Entity Framework code first/Creating Context class with Entity Framework from scratch sample

Transactions Manipulating data(Inserting entities, Updating entities, Deleting entities, querying entities) Introduction in Entity Framework Introduction in Entity Framework What is Entity Framework?

Short history Pros/Cons in using EF Core Introduction in Entity Framework What is Entity Framework?

Short history Pros/Cons in using EF Core Introduction in Entity Framework What is Entity Framework? Short history It is an ORM => object relational

mapping tool from Microsoft. Pros/Cons in using EF Core Introduction in Entity Framework What is Entity Framework? Short history

Pros/Cons in using EF Core Introduction in Entity Framework Was first released as part of .NET Framework 3.5 with Service Pack 1 back in late 2008. What is Entity Framework? Short history

Pros/Cons in using EF Core Introduction in Entity Framework The version included with Visual Studio 2015 is Entity Framework 6.1.3 (EF6). What is Entity Framework? Short history

Pros/Cons in using EF Core Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core

is mature, stable, and supports the "old" EDMX design-time way Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core

Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core Pros Cons

Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core Pros Is available for .NET Core => can be used for Mac, Linux or

Windows Cons Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core

Pros Is available for .NET Core => can be used for Mac, Linux or Windows Supports modern cloud-based, non-relational databases(Azure table Storage, Redis) Cons Introduction in Entity Framework What is Entity Framework?

Short history Pros/Cons in using EF Core Pros Is available for .NET Core => can be used for Mac, Linux or Windows Supports modern cloud-based, non-relational databases(Azure Table Storage, Redis) Cons Does not support the old EDMX

design time Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core Pros

Cons Is available for .NET Core => can be used for Mac, Linux or Windows Does not support the old EDMX design time Supports modern cloud-based, non-relational databases(Azure Table Storage, Redis) Does not support yet complex inheritance models

Introduction in Entity Framework What is Entity Framework? Short history Pros/Cons in using EF Core Pros Cons

Is available for .NET Core => can be used for Mac, Linux or Windows Does not support the old EDMX design time Supports modern cloud-based, non-relational databases(Azure Table Storage, Redis) Does not support yet complex inheritance models Tip: Use EF6 for Windows platform applications until EF Core becomes more stable and implements more features. Use EF

Core for cross-platform development. Entity Framework code first Entity Framework code first - conventions Entity Framework code first - conventions If a connection string exists with the same name as the class derived from DbContext, then it is loaded and used to connect to the database automatically. Entity Framework code first - conventions

If a connection string exists with the same name as the class derived from DbContext, then it is loaded and used to connect to the database automatically. The name of a table is assumed to match the name of a DbSet property in the DbContext class, for example, Customers. Entity Framework code first - conventions If a connection string exists with the same name as the class derived

from DbContext, then it is loaded and used to connect to the database automatically. The name of a table is assumed to match the name of a DbSet property in the DbContext class, for example, Customers. The names of the columns are assumed to match the names of properties in the class, for example, CustomerID. Entity Framework code first - conventions

If a connection string exists with the same name as the class derived from DbContext, then it is loaded and used to connect to the database automatically. The name of a table is assumed to match the name of a DbSet property in the DbContext class, for example, Customers. The names of the columns are assumed to match the names of properties in the class, for example, CustomerID.

The string .NET type is assumed to be an nvarchar type in the database. Entity Framework code first - conventions If a connection string exists with the same name as the class derived from DbContext, then it is loaded and used to connect to the database automatically. The name of a table is assumed to match the name of a DbSet property in the DbContext class, for example, Customers.

The names of the columns are assumed to match the names of properties in the class, for example, CustomerID. The string .NET type is assumed to be an nvarchar type in the database. The int .NET type is assumed to be an int type in the database. Entity Framework code first - conventions

If a connection string exists with the same name as the class derived from DbContext, then it is loaded and used to connect to the database automatically. The name of a table is assumed to match the name of a DbSet property in the DbContext class, for example, Customers. The names of the columns are assumed to match the names of properties in the class, for example, CustomerID.

The string .NET type is assumed to be an nvarchar type in the database. The int .NET type is assumed to be an int type in the database. A property that is named ID or the name of the class has ID as the suffix, it is assumed to be a primary key. If this property is any integer type or the Guid type, then it is also assumed to be an IDENTITY Entity Framework code first

attributes Entity Framework code first attributes With attributes we can specify different aspects database oriented: Not Null field, dimensions for nvarchar, custom types Entity Framework code first attributes With attributes we can specify different aspects database oriented: Not Null field, dimensions for nvarchar, custom types [Required]

[StringLength(40)] public string CustomerName { get; set; } or: Entity Framework code first attributes With attributes we can specify different aspects database oriented: Not Null field, dimensions for nvarchar, custom types [Required] [StringLength(40)] public string CustomerName { get; set; } or:

[Column( TypeName = "money")] public decimal? UnitPrice { get; set; } Entity Framework code first Fluent API Entity Framework code first Fluent API It can be used: Combined with attributes Entity Framework code first Fluent

API It can be used: Combined with attributes As a replacement for attributes Entity Framework code first Fluent API

It can be used: Combined with attributes As a replacement for attributes [Required] [StringLength( 40)] public string CompanyName { get; set; } They could be deleted and replaced with this Fluent API statement in the Context class OnModelBuilding method: modelBuilder.Entity() .Property(customer=>customer.CompanyName)

.IsRequired() .HasMaxLength(40); Entity Framework code first models and context class Creating models with Entity Framework code first/Creating Context class with Entity Framework from scratch sample - Demo Entity Framework code first transactions Entity Framework code first transactions

Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is occurring. Entity Framework code first transactions Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is occurring. Transactions should be ACID.

Entity Framework code first transactions Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is occurring. Transactions should be ACID. A : is for atomic

Entity Framework code first transactions Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is occurring. Transactions should be ACID. A : is for atomic

C: is for consistent Entity Framework code first transactions Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is occurring. Transactions should be ACID.

A : is for atomic C: is for consistent I: is for isolated Entity Framework code first transactions Transactions maintain the integrity of your database by applying locks to prevent reads and writes while a sequence of operations is

occurring. Transactions should be ACID. A : is for atomic C: is for consistent I: is for isolated

D: is for durable Entity Framework code first manipulating data Entity Framework code first manipulating data Inserting entities

Updating entities Deleting entities Querying entities Entity Framework code first manipulating data Inserting entities

Updating entities Deleting entities Querying entities Entity Framework code first manipulating data

Inserting entities Updating entities Deleting entities Querying entities Entity Framework code first manipulating data

Inserting entities Updating entities Deleting entities Querying entities

Entity Framework code first manipulating data Inserting entities Updating entities Deleting entities

Querying entities Entity Framework code first manipulating data Inserting entities Updating entities Deleting entities

Querying entities Entity Framework code first manipulating data Inserting entities Updating entities

Deleting entities Querying entities Entity Framework code first manipulating data Inserting entities Updating entities

Deleting entities Querying entities Entity Framework code first manipulating data Inserting entities

Updating entities Deleting entities Querying entities Whats next Entity Framework Core part 2 One more thing

Read the story from notes!!!!! One more thing Read the story from notes!!!!! Early one morning, a programmer asked the great master: I am ready to write some unit tests. What code coverage should I aim for? The great master replied: Dont worry about coverage, just write some good tests. The programmer smiled, bowed, and left. ...

Questions Do you have any other questions? Thanks! See you next time!

Recently Viewed Presentations

  • Voyage of a Reluctant Online Instructor - thaicyberu.go.th

    Voyage of a Reluctant Online Instructor - thaicyberu.go.th

    Voyage of a Reluctant Online Instructor. ... 2003-You will be taking the six week online training program on Webtycho "Success is survival, and we all tough it out." Twenty-two Professors and Instructors started that Webtycho Training Program in 2003. Only...
  • The Key Points We Want To Cover 1

    The Key Points We Want To Cover 1

    The Key Points We Want To Cover Two Challenges Facing All Generations Today's Reality The Power of a USANA Home-based Business Network Marketing Has Come of Age The Benefits of
  • HIDDEN DESCRIPTION SLIDE  NOT TO BE SHOWN TO

    HIDDEN DESCRIPTION SLIDE NOT TO BE SHOWN TO

    Selling today cannot avoid yesterday's losses in a down market. Likewise, in an up market, you cannot buy yesterday's performance by investing in the hottest fund. If you absolutely have to make changes in your portfolio, consider making them in...
  • Essential Oils - Michigan Association of Naturopathic Physicians

    Essential Oils - Michigan Association of Naturopathic Physicians

    Essential oils What is an essential oil??? The blood of the plant protects the plant from invaders Helps the plant to heal from any wound Subtle volatile liquids distilled from plants, shrubs, flowers, trees, roots, brushes, and seeds.
  • Animal Science 434 Reproductive Physiology

    Animal Science 434 Reproductive Physiology

    Front View. Spermatic Artery. Fusion of Peritoneum and Gubernaculum. Gubernaculum. Inguinal Ring. Peritoneum. Testis. Visceral Growth. Visceral Growth. ... Female born twin to a bull. Placenta membranes of the 2 fetuses fuse. Common blood supply. At time of testis formation.
  • Part I: Introduction - Sorin Adam Matei

    Part I: Introduction - Sorin Adam Matei

    "network of networks" loosely hierarchical. Nestled into each other (onion metaphor) Internet standards. Open. Free. Protocols - the only thing that is unique to the Internet are its specific standards. local ISP. company. network. regional ISP. router. workstation. server. mobile
  • Feasibility Report to Switch to Green Power

    Feasibility Report to Switch to Green Power

    Grade: 25/25 Excellent work Feasibility Report for a Green Power System June 20, 2011 TCO 341- Codone Problem Crude Oil Systems have downtimes and greatly pollute our environment Price of Crude oil went up 100% within 40 years Non-Renewable resources...
  • Ecohydrology of Dry Ecosystems: Rainfall in Central Kenya

    Ecohydrology of Dry Ecosystems: Rainfall in Central Kenya

    Ecohydrology of Dry Ecosystems: Rainfall in Central Kenya Kathleen Ryan '14 Caylor Ecohydrology Lab Mpala Research Center Caylor Ecohydrology Lab "…seeks to develop improved insight into the way that land use and climate change are interacting to affect the hydrological...