Objective
See my blog about the new features of ASP. NET Core 2.0. This article is some of the improvements in PRIVIEW2.
. NET Core 2.0-preview2
- Improvements to Azure
- The Docker image is transferred to the Debian Stretch
- Repair and support for MacOS high Sierra
- Improvements in quality and performance
dotnet restore
will be implicitly called when Dotnet Run,publish,build.
- The. NET Standard library can reference the. NET Framework Library
- The. NET Standard NuGet Package Nuspec no longer needs to be added for
NETStandard.Library
dependency relationships
ASP. NET Core 2.0-preview2
Updated templates for Visual Studio and more templates for spa projects. Including (Angular, React.js, React.js and Redux) and so on.
Added a template for creating a new ASP. NET Core Project in Visual Studio 2017.
- Kestrel has added some configuration options, including (Maxconcurrentconnections,maxrequestbodysize,requestbodyminimumdatarate), and so on.
- Razor supports C # 7.1. This configuration can be enabled in Csproj
<LangVersion>latest</ LangVersion>
.
- Added support for Filestreamresult,filecontentresult HTTP headers in MVC action. Now you can add ETag, lastupdate and so on.
- Two new Filters (Ipagefilter,iasyncpagefilter) for Razor page have been added.
About the Identity-related services in Priview 1 There are also configuration https cut off, they also need time to polish, waiting for later release.
Entity Framework Core 2.0-preview2
- New NuGet Packages and kits (Microsoft.EntityFrameworkCore.Tools.DotNet)
- The string interpolation in Fromsql and Executesqlcommand, and the SQL they generate will be automatically parameterized.
var city = "London";var contactTitle = "Sales Representative";using (var context = CreateContext()){ context.Customers .FromSql($@" SELECT * FROM Customers WHERE City = {city} AND ContactTitle = {contactTitle}") .ToArray();}
Generated sql:
@p0=‘London‘ (Size = 4000)@p1=‘Sales Representative‘ (Size = 4000)SELECT *FROM CustomersWHERE City = @p0 AND ContactTitle = @p1
- Entity type Auto-split table (functions in Priview1), only one table will be created below.
ModelBuilder.Entity<order> ().Ownsone (P = p.OrderDetails, CB = CB.Ownsone (c = c.billingaddress); Cb.Ownsone (c = c.shippingaddress); });PublicClassorder{Publicint Id {GetSet }Public OrderDetails OrderDetails {GetSet }}PublicClassorderdetails{Public Address billingaddress {Getset;} public Address shippingaddress { get; set;} public class address{public string Street {get; set;} public string City {get; set;}}
- Database function mapping, you can use the functions defined in the database in your code, and note that the return value can only be single (scalar).
public class BloggingContext : DbContext{ [DbFunction] // 添加这个标记,静态方法 public static int PostReadCount(int blogId) { throw new Exception(); }}
The Postreadcount function defined in the database will be called, and the function must be created manually, and EF will not be generated automatically.
var query = from p in context.Posts where BloggingContext.PostReadCount(p.Id) > 5 select p;
- Other improvements (compatibility, outdated APIs, etc.)
Original: http://www.cnblogs.com/savorboard/p/dotnetcore2-feature.html
. NET Core 2.0 PREVIEW2 Release Rollup