- Created by: Bolton Uni Jay
- Created on: 01-07-19 14:57
Technologies relating to VS17, ASP.NET & .NET 1
ADO.Net (ActiveX Data Object.NET) is a software library in the .NET framework consisting of software components providing data access services. ADO.NET is designed to enable developers to write managed code for obtaining disconnected access to data sources, which can be relational or non-relational (such as XML or application data). This feature of ADO.NET helps to create data-sharing, distributed applications.
Internet Information Server Express (IIS Express) is a cut-down development version of Internet Information Server (IIS), which is an extensible web server created by Microsoft for use with the Windows NT family( <-- IIS is, NOT IIS Express). IIS Express supports only the HTTP and HTTPS protocols.
LocalDB is a minimal, on-demand, version of SQL Server that is designed for application developers. It can also be used as an embedded database. SQL Server is a relational database management system developed by Microsoft.
Technologies relating to VS17, ASP.NET & .NET 2
NuGet Package Manager is a free and open-source package manager designed for the Microsoft development platform. It supports multiple programming languages, including:
- .NET Framework packages
- Native packages written in C++, with package creation aided by CoApp
Language Integrated Query (LINQ) is a Microsoft .NET Framework component which adds query capabilities to the .NET programming languages. These extensions provide shorter and expressive syntax to manipulate data. A number of features have been added to C# and Visual Basic to support LINQ.
About the .NET platform
The .NET Framework is a development platform for building apps for web, Windows, Windows Phone, Windows Server, and “for the cloud” on Microsoft Azure (MS’ cloud hosting platform)
.NET Framework consists of the Framework Class Library (FCL) and Common Language Runtime (CLR)
.NET history and variants
.NET Framework is Windows only (Can't run on other OS and is traditionally closed source)
.NET Framework Version 1.0 is the first version of NET Framework used in the first version of Visual Studio .NET in 2002
Free & Open source managed framework (as is .NET Framework) but intended to be platform agnostic (Platform Agnostic means it'll run on near enough any computer operating system such as Linux, Unix, Windows, Mac, etc. For example, Acrobat Reader.).
Therefore it is supported on Windows, Linux and macOS currently (and more potentially in the future).
It supports: C#, F# and (partly) Visual Basic.NET
It does NOT support: C++/CLI
Applications written for .NET Core will run unmodified on any supported operating system (similar to Java therefore)
1.0 Release was in 2016, 3.0 Released in 2019
About the .NET platform - Framework Class Library
FCL is a component of Microsoft's .NET Framework. It is a library of reusable/core classes, interfaces and value types which allow developers to access and use functionality in the .NET Framework.
It defines and implements this functionality in a number of commonly used namespace families:
About the .NET platform - Common Language Runtime
Common Language Runtime (CLR) is the virtual machine component of Microsoft's .NET framework.
It runs (executes) code compiled for the .NET platform.
The complied code is compiled/MS intermediate language (MSIL) code
Just-in-time compilation (JIT) converts the managed code (compiled/MS intermediate language (MSIL) code) into Machine Code executed by the CPU.
CLR has a degree of language-neutrality (Means doesn't have a specific language) because more than 1 .NET language exists (e.g. C#, C++/CLI, F# & Visual Basic.Net (VB.Net) are MS’ official ones but third-party ones exist also).
MVC is an application design model comprised of three interconnected parts. They include the model (data), the view (user interface), and the controller (processes that handle input).
The MVC model or "pattern" is commonly used for developing modern user interfaces. It is provides the fundamental pieces for designing a programs for desktop or mobile, as well as web applications. It works well with object-oriented programming, since the different models, views, and controllers can be treated as objects and reused within an application.
Databases & Object/Relational Mappers (ORMs) 1
As you’ve been seeing (and building) in this module, websites that are dynamic, normally draw their dynamic data from databases.
A back-end server database product is therefore a key component of most data-driven websites.
Examples of database server products include:
- MS SQL Server
- IBM Db2
While you can technically use desktop and embedded database products (such as Access, Paradox and LocalDB) on web servers in place of the above, you really shouldn’t.
Databases & Object/Relational Mappers (ORMs) 2
Object/Relational Mapper (ORM) is a programming technique that lets you manipulate data from a database using an object-oriented paradigm.
An ORM library is a library written in your language of choice that expresses the code needed to manipulate the data (so SQL isn't necessary).
An example of ORM being used: https://prnt.sc/o93znl
Here are a few of the things ORMs (Like Entity Framework) can do:
- Wrap database access
- Permit a native, type-safe representation of a database’s tables, views, stored procedures etc as a collection of “regular” objects within the target programming language which can then be used by the programmer as though they were in-memory collections
(Thus the complexity of accessing database is further abstracted and hidden from the developer (compared to ADO.NET on it’s own and especially compared with not using any database frameworks at all)
Databases & Object/Relational Mappers (ORMs) 3
ORM - PROS:
- Saves time (removes most of the need to write database mapping code to map data to class objects or vice versa)
- Reduces errors and increases robustness – changes to application if database changes are easier
- Reduces maintenance overheads and headaches
- Easier than embedding SQL statements into code
- More secure, removes opportunity for SQL injection attacks
- It can forces you to write MVC code, which, in the end, makes your code a little cleaner.
- It fits in your natural way of coding
ORM - Cons
- You have to learn it, and ORM libraries are not lightweight tools;
- You have to set it up. Same problem.
- Performance is OK for usual queries, but a SQL master will always do better with his own SQL for big projects.
Databases & Object/Relational Mappers (ORMs) 4
Popular ORMs include:
- Entity Framework
- LINQ to DB
- Eclipse Link
Entity Framework supports two different approaches/ways of working with databases with an ORM; Code-First & Database-First.
The Database First Approach creates model codes (classes, properties, DbContext etc.) from the database in the project and those classes become the link between the database and controller.
The Database First Approach creates the entity framework from an existing database. We use all other functionalities, such as the model/database sync and the code generation, in the same way we used them in the Model First approach.
The Code First Approach focuses on the domain of your application and starts creating classes for your domain entity rather than design your database first and then create the classes which match your database design. Code First allows you to define your model using C# or VB.Net classes.
Take the quiz to gauge
how well you know both.
Working with Entity Framework
Once added to a project, aside from creating and using collections within a DB Context class and its related model classes, the primary interaction with Entity Framework during development is via the NuGet package manager console (NPMC) (not very intuitive to newbies I know!)
There are a variety of commands that can be issued via the NPMC to Entity Framework but the main ones we’ve used include these two used to create migrations and apply them to (update) the database:
Some other common NPMC Entity Framework related commands:
3-tier architecture for internet applications 1
An architectural pattern separating an application into 3 (presentation tier, application tier & data tier) distinct, purposeful areas to bring many advantages of modularity & allow any tier to be upgraded/replaced with minimal or (sometimes) no changes to the other layers (E.g. replacing OS in presentation layer only affects UI not business logic.).
The data tier stores information, the application tier handles logic and the presentation tier is a graphical user interface (GUI) that communicates with the other two tiers. The three tiers are logical, not physical, and may or may not run on the same physical server.
- Top level of application, part of the system users see and interact with – UI, display screen output etc.
- In context of internet applications normally rendered by/executed in web browser serving content requested from web server
- May includes client side programming/markup that implements client portion of the application
3-tier architecture for internet applications 2
- Logic later that receives data/infrastructure from presentation tier
- Carries out processing
- Implements data persistence mechanisms (database servers, file sharing, cloud based storage etc.)
- Encapsulates the mechanisms and exposes means to access the data without creating dependencies on the underlying storage mechanism’s technology (e.g. using an ORM does this)
Web server software
Web server software is software that runs on servers that can satisfy World Wide Web client requests. A web server can contain one or more web sites.
Popular server implementations include:
- Internet Information Services, Microsoft’s web server for Windows
- Apache HTTP, a cross-platform open source web server for UNIX-like and Windows systems
All web servers implement the HTTP standard meaning they can all receive and respond to requests from standard WWW clients (internet browsers)
- HTTP = Hyper Text Transfer Protocol
- HTTPS = Secure (encrypted) implementation of HTTP using SSL (Secure Sockets Layer)
- Primary role of both is for transmitting website data across the internet
Single Page Applications 1/2
A single-page application is a web application or web site that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server.
- The browser does not carry out any further full page request/reload operations after the first time the site is loaded and rendered
- Prevents interruption of the user experience between successive pages
Single Page Applications 2/2
- Initial load of the application can be slower than for a traditional non SPA web-based application
- SPA’s communicates with a web server that typically hosts an implementation of the business logic and data layers, thus the SPA is primarily a presentation-layer consideration.
Examples of SPA frameworks include: