Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer

Slides:



Advertisements
Similar presentations
Windows Basic and Dynamic Disk Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator Marian Marinov CEO of 1H Ltd.
Advertisements

HTML Forms, GET, POST Methods Tran Anh Tuan Edit from Telerik Academy
Amazon S 3, App Engine Blobstore, Google Cloud Storage, Azure Blobs Svetlin Nakov Telerik Software Academy academy.telerik.com.
RPN and Shunting-yard algorithm Ivaylo Kenov Telerik Software Academy academy.telerik.com Technical Assistant
Telerik School Academy ASP.NET MVC.
Shortest paths in edge-weighted digraph Krasin Georgiev Technical University of Sofia g.krasin at gmail com Assistant Professor.
Telerik Software Academy Telerik School Academy.
Asynchronous Programming with C# and WinRT
Unleash the Power of JavaScript Tooling Telerik Software Academy End-to-end JavaScript Applications.
Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Telerik Software Academy Telerik School Academy.
Telerik School Academy ASP.NET MVC.
Character sequences, C-strings and the C++ String class, Working with Strings Learning & Development Team Telerik Software Academy.
Hybrid or Native?! Doncho Minkov Telerik Software Academy Senior Technical Trainer
Done already for your convenience! Telerik School Academy Unity 2D Game Development.
C# Fundamentals – Part I
NoSQL Concepts, Redis, MongoDB, CouchDB
Telerik Software Academy Telerik School Academy Creating E/R Diagrams with SQL Server.
The Business Plan and the Business Model Margarita Antonova Volunteer Telerik Academy academy.telerik.com Business System Analyst Telerik Corporation.
Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
What are ADTs, STL Intro, vector, list, queue, stack Learning & Development Team Telerik Software Academy.
Making JavaScript code by template! Learning & Development Team Telerik Software Academy.
Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training Who, What, Why?
Svetlin Nakov Telerik Software Academy Manager Technical Training
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Accessing SQL Server and MySQL – Live Demo Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Learning & Development Telerik Software Academy.
Reading and Writing Text Files Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Telerik Software Academy ASP.NET Web Forms.
Classical OOP in JavaScript Classes and stuff Telerik Software Academy
Using Selenium for Mobile Web Testing Powered by KendoUI Telerik QA Academy Atanas Georgiev Senior QA Engineer KendoUI Team.
NoSQL Concepts, Redis, MongoDB, CouchDB Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
New features: classes, generators, iterators, etc. Telerik Academy Plus JavaScript.Next.
Creating E/R Diagrams with SQL Server Management Studio and MySQL Workbench Svetlin Nakov Telerik Software Academy Manager Technical.
Throwing and Catching Exceptions Tran Anh Tuan Edit from Telerik Software Academy
Loops, Conditional Statements, Functions Tran Anh Tuan Edit from Telerik Academy
Private/Public fields, Module, Revealing Module Learning & Development Team Telerik Software Academy.
Building Data-Driven ASP.NET Web Forms Apps Telerik Software Academy ASP.NET Web Forms.
Course Introduction Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Telerik Software Academy End-to-end JavaScript Applications.
Planning and Tracking Software Quality Yordan Dimitrov Telerik Corporation Team Leader, Team Pulse, Team Leader, Team Pulse, Telerik Corporation,
What you need to know Ivaylo Kenov Telerik Corporation Telerik Academy Student.
Data binding concepts, Bindings in WinJS George Georgiev Telerik Software Academy academy.telerik.com Technical Trainer itgeorge.net.
Pavel Kolev Telerik Software Academy Senior.Net Developer and Trainer
Objects, Properties, Primitive and Reference Types Learning & Development Team Telerik Software Academy.
ORM Concepts, Entity Framework (EF), DbContext
When and How to Refactor? Refactoring Patterns Alexander Vakrilov Telerik Corporation Senior Developer and Team Leader.
Free Training and Job for Software Engineers Svetlin Nakov, PhD Manager Technical Training Telerik Corp. Telerik Software Academy.
Access to known folders, using pickers, writing to and reading from files, caching files for future access George Georgiev Telerik Software Academy academy.telerik.com.
Doing the Canvas the "easy way"! Learning & Development Telerik Software Academy.
Creating and Running Your First C# Program Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical Training
Course Overview Doncho Minkov Telerik Software Academy Technical Trainer
Learn to Design Error Steady Code Svetlin Nakov Telerik Software Academy academy.telerik.com Technical Trainer
Connecting, Queries, Best Practices Tran Anh Tuan Edit from Telerik Software Academy
Processing Sequences of Elements Telerik Software Academy C# Fundamentals – Part 2.
Telerik JavaScript Framework Telerik Software Academy Hybrid Mobile Applications.
Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer ORM Concepts, Entity Framework.
Building Rock-Solid Software Nikolay Kostov Telerik Software Academy academy.telerik.com Senior Software Developer and Technical Trainer
Telerik Software Academy Databases.
Things start to get serious Telerik Software Academy JavaScript OOP.
Learning & Development Mobile apps for iPhone & iPad.
Working with Data Model Binders, Display Templates, Editor Templates, Validation… SoftUni Team Technical Trainers Software University
Processing Matrices and Multidimensional Tables Telerik Software Academy C# Fundamentals – Part 2.
Nikolay Kostov Telerik Software Academy academy.telerik.com Team Lead, Senior Developer and Trainer
ASP.NET Web API Telerik Software Academy
Functions and Function Expressions Closures, Function Scope, Nested Functions Telerik Software Academy
Implementing Control Logic in C# Svetlin Nakov Telerik Software Academy academy.telerik.com Manager Technical trainer
Mocking tools for easier unit testing Telerik Software Academy High Quality Code.
What why and how? Telerik School Academy Unity 2D Game Development.
Windows Security Model Borislav Varadinov Telerik Software Academy academy.telerik.com System Administrator
Presentation transcript:

Nikolay Kostov Telerik Software Academy Senior Software Developer and Trainer

 ADO.NET Entity Framework and LINQ  Code-first approach  Scaffolding  Model Binders  Data Validation  Kendo UI Grids 2

Object Relation Persistence Framework

 Entity Framework (EF) is a standard ORM framework, part of.NET  Provides a run-time infrastructure for managing SQL-based database data as.NET objects  The relational database schema is mapped to an object model (classes and associations)  Visual Studio has built-in tools for generating Entity Framework SQL data mappings  Data mappings consist of C# classes and XML  A standard data manipulation API is provided 4

 Entity Framework (EF) standard features:  Maps tables, views, stored procedures and functions as.NET objects  Provides LINQ-based data queries  Executed as SQL SELECTs on the database server  CRUD operations – Create/Read/Update/Delete  Create compiled queries – for executing the same parameterized query multiple times  Creating or deleting the database schema 5

 When the application starts  EF translates into SQL the language-integrated queries in the object model  Sends them to the database for later execution 6

 When the database returns the results  Entity Framework translates the database rows back to.NET objects  The database server is transparent, hidden behind the API  LINQ is executed over IQueryable  LINQ is executed over IQueryable  At compile time a query expression tree is emitted  At runtime SQL is generated and executed 7

 The ObjectContext class  ObjectContext holds the database connection and the entity classes  Provides LINQ-based data access  Implements identity tracking, change tracking, and API for CRUD operations  Entity classes  Each database table is typically mapped to a single entity class (C# class) 8

 Associations  An association is a primary key / foreign key based relationship between two entity classes  Allows navigation from one entity to another, e.g. Student.Courses  Concurrency control  Entity Framework uses optimistic concurrency control (no locking by default)  Provides automatic concurrency conflict detection and means for conflicts resolution 9

 Comprehension Query Syntax  Extension Method Syntax 10

11 Entity Framework (+ LINQ) Entity Framework (+ LINQ) Schema First (database) Schema First (database) Model First (model designer) Model First (model designer) Code First (C# classes) Code First (C# classes) SQL Server (compact) SQL Server (compact) MySQL Azure (cloud) Oracle

What is Microsoft SQL Server?What is Microsoft SQL Server?  MS SQL Server is a Relational Database Management System (RDBMS) from Microsoft  The main language supported in SQL Server is Transact SQL (T-SQL), an extension of SQL  Powerful, trustworthy, easy-to-use DB server  The most recent version is SQL Server 2012  Works only on Windows systems  A free distribution exists (SQL Server Express) 

13 Design First Code First New Database Existing Database Model First Create.edmx model in designer Generate DB from.edmx Classes auto-generate from.edmx Database First Reverse engineer.edmx model Classes auto-generate from.edmx Code First Define classes & mapping in code Database auto-created at runtime Code First Define classes & mapping in code

14

 Convention over configuration  Database naming  Primary Key  Relationships (navigation properties)  Data Annotations  Tells EF how to map the object model to the database model  Place annotations directly against the property in your class  System.ComponentModel.DataAnnotations 15

 Key – Defines a Primary Key  Column – Defines DB column name  Table – Defines table name for a class  Required – Defines a Required DB field  NotMapped – Property not in DB mapping  MinLength() – Min length for a property  MaximumLength() – Max length for property  Range() – Defines a valid value range 16

 Package Manager Console  Enable-Migrations (-ContextTypeName)  This creates a Migration folder in project  Creates Configuration.cs file  AutomaticMigrationsEnabled = true;  Seed method to populate some initial data  Creates __MigrationHistory system table in DB  Update-Database (-Verbose)  Pushes the migration changes to the DB  –script – create a SQL script of the changes 17

 When the database doesn’t match conventions … 18

Please work, please work, please work…

 TODO: Editor templates and view templates 21

 To make east of handling HTTP post request  Help the populating the parameters in action methods 23 DefaultModelBinder

24

 Attributes defined in System.ComponentModel.DataAnnotations  Covers common validation patterns  Required  StringLength  Regex  Range 26

27 AttributeDescription CompareChecks whether two specified properties in the model have the same value. CustomValidationChecks the value against the specified custom function. EnumDataTypeChecks whether the value can be matched to any of the values in the specified enumerated type. RangeChecks whether the value falls in the specified range. It defaults to numbers, but it can be configured to consider a range of dates, too. RegularExpressionChecks whether the value matches the specified expression. RemoteMakes an Ajax call to the server, and checks whether the value is acceptable. RequiredChecks whether a non-null value is assigned to the property. It can be configured to fail if an empty string is assigned. StringLengthChecks whether the string is longer than the specified value.

 Custom attributes  Inherit ValidationAttribute 28

 ModelState.IsValid – will give us information about the data validation success  ModelState.AddModelError – custom error 29

– output errors – outputs validation message for specified property 30 Text box with integrated client-side validation jQuery validation library required for unobtrusive JavaScript validation

31 AttributeDescription DisplayColumnSpecify the property of a model class for simple text display. HiddenInputRender value in a hidden input (when editing). UIHintSpecify the name of the template to use for rendering. DataTypeCommon templates ( , password, URL, currency) ReadOnlySpecify a read-only property (for model binding). DisplayFormatFormat strings and null display text ScaffoldColumnTurn off display and edit capabilities DisplayNameFriendly name for labels

 TODO: Kendo Grids

 TODO: Summary 34

форум програмиране, форум уеб дизайн курсове и уроци по програмиране, уеб дизайн – безплатно програмиране за деца – безплатни курсове и уроци безплатен SEO курс - оптимизация за търсачки уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop уроци по програмиране и уеб дизайн за ученици ASP.NET MVC курс – HTML, SQL, C#,.NET, ASP.NET MVC безплатен курс "Разработка на софтуер в cloud среда" BG Coder - онлайн състезателна система - online judge курсове и уроци по програмиране, книги – безплатно от Наков безплатен курс "Качествен програмен код" алго академия – състезателно програмиране, състезания ASP.NET курс - уеб програмиране, бази данни, C#,.NET, ASP.NET курсове и уроци по програмиране – Телерик академия курс мобилни приложения с iPhone, Android, WP7, PhoneGap free C# book, безплатна книга C#, книга Java, книга C# Николай Костов - блог за програмиране

 “C# Telerik Academy  csharpfundamentals.telerik.com csharpfundamentals.telerik.com  Telerik Software Academy  academy.telerik.com academy.telerik.com  Telerik Facebook  facebook.com/TelerikAcademy facebook.com/TelerikAcademy  Telerik Software Academy Forums  forums.academy.telerik.com forums.academy.telerik.com