Rank function will generates a unique number to each distinct row, but it leaves a gap between the groups.
Dense_Rank()
Dense_Rank function is similar to Rank with only difference, this will not leave gaps between groups.
DECLARE @Table TABLE (
column varchar(2)
)
INSERT INTO @Table (column)
VALUES ('A'),('A'),('A'),('B'),('B'),('C'),('C');
SELECT
Col_Value,
Rank() OVER (ORDER BY column) AS 'Rank',
DENSE_RANK() OVER (ORDER BY Col_Value) AS 'DENSE_RANK'
FROM
@Table;
Time to compare both the view and notice that using Tag Helpers, created form contains look like HTML elements.
It meant form contains an Input element instead of Html.TextBoxFor() helper. So it would be fine HTML designer fine with this page.
Tag Helpers introduce one special asp-for attributes on html tag. These attributes are used to extend the elements with server side Asp.Net MVC functionality.
4. View Components
Time to say Goodbye subcontrollers and adapt View Components.
If you remember, in previous versions of ASP.NET MVC, the Html.Action() helper is typically used to invoke a sub-controller. A sub-controller may display stuff like tag clouds, dynamic links, side bars or whatever.
ASP.NET MVC 6 introduced the new View Component to replace widgets that use Html.Action().
Lets create one a View Component that displays Simple text.
using Microsoft.AspNet.Mvc;
using System;
namespace Partials.Components
{
public class TextPrint : ViewComponent
{
public IViewComponentResult Invoke()
{
return View("_TextPrint", "Hello This is for test!");
}
}
}
Here how look like the _TextPrint partial.
@model string
@Model
Now, let see how we can usre the TextPrint View Compenent in MVC view.
@Component.Invoke("TextPrint")
View Components are very similar to subcontrollers.
However, subcontrollers were always a little odd.
They were pretending to be controller actions but they were not really controller actions.
5. Many Client side framework supported. (Gulp, NPM and Bower Support)
Front-end development gets a lot of love in Asp.Net 5 through its support for Gulp.
GruntJS is a task runner that enables you to build front-end resources such as JavaScript and CSS files. For example, you can use GruntJS to concatenate and minify your JavaScript files whenever you perform a build in Visual Studio.
In order to support GruntJS, Microsoft needed to support two new package managers (beyond NuGet). First, because GruntJS plugins are distributed as NPM packages, Microsoft added support for NPM packages.
Second, because many client-side resources – such as Twitter Bootstrap, jQuery, Polymer, and AngularJS – are distributed through Bower, Microsoft added support for Bower.
This means that you can run GruntJS using plugins from NPM and client resources from Bower.
6. Common Controllers for MVC and Web API
In previous versions of ASP.NET MVC, MVC controllers were different than Web API controllers. An MVC controller used the System.Web.MVC.Controller base class and a Web API controller used the System.Web.Http.ApiController base class.
In MVC 6, there is one and only one Controller class that is the base class for both MVC and Web API controllers. There is only the Microsoft.AspNet.Mvc.Controller class.
MVC 6 controllers return an IActionResult. When used as an MVC controller, the IActionResult might be a view. When used as a Web API controller, the IActionResult might be data (such as a list of products). The same controller might have actions that return both views and data.
In MVC 6, both MVC controllers and Web API controllers use the same routes. You can use either convention-based routes or attribute routes and they apply to all controllers in a project.
7. AngularJS
Now a days AngularJs is most popular client-side frameworks for building SPAs (Single Page Applications).
So for fortunatly Visual Stdio 2015 includes templates for creating AngularJS modules, controllers, directives and factories.
The support in ASP.NET 5 for Gulp makes ASP.NET an excellent server-side framework for building client-side AngularJS apps.
You can combine and minify all of your AngularJS files automatically whenever you perform a build.
You can interact with an MVC 6 controller from an AngularJS $resource using REST.
8. Inbuilt Dependency Injection Framework
ASP.NET 5 has built-in support for Dependency Injection and the Service Locator pattern. This means that you no longer need to rely on third-party Dependency Injection frameworks such as Ninject or AutoFac.
Previously need do many things for Dependency Injection and Resolver but in Asp.Net 5 has built-in support.
In Asp.Net 5 you can use the [Activate] attribute to inject services via properties.
You can use [Activate] not just on controllers but also on filters and view components.
Lets see how to inject class/services.
public class HomeController : Controller
{
[Activate]
public TestClass TestClass { get; set; }
}
Asp.Net 5 also supports Dependency Injection into Razorviews via the @inject keyword.
Lets see how to inject TestClass into the view directly and defined a TestClass property by which it can be accessed.
In Asp.Net we can say Goodbye Visual Studio Unit Testing Framework and welcome to xUnit.net.
Previous versions of Asp.Net MVC, the default testing framework was the Visual Studio Unit Testing Framework. This framework uses the [TestClass] and [TestMethod] attributes to describe a unit test.
[TestClass]
public class ProductTests {
[TestMethod]
public void TestAddProduct() {
//Write your code
}
}
In Asp.Net 5 replace the [TestClass] and [TestMethod] to [Fact] attribute.
It means xUnit.net framework uses the [Fact] attribute.
xUnit just use [Fact] attribute while previous version unit test framework used [TestMethod] and [TestClass].
public class ProductTests {
[Fact]
public void TestAddProduct() {
//Write your code
}
}
Asp.Net 5
It is an open source cross-platform framework for building modern web applications that can be developed and run cross-platforms like Windows, Linux and the Mac. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions. It includes the MVC 6 framework, which now combines the features of MVC and Web API into single web programming framework.
Asp.Net MVC 6
It is a web application framework developed by Microsoft, Which implements the MVC (model-view-controller) patter.
Hope you getting basic idea about next version of Asp.Net. So please keep reading blog post and give your suggestion and comment for improvements.
Next post for Asp.Net 5 improvements.