Download presentation
Presentation is loading. Please wait.
1
Working with SQL Server using .NET Standard 2.0
Marco Minerva @marcominerva Working with SQL Server using .NET Standard 2.0
2
Sponsor
3
.NET Standard 2.0
4
.NET today – reusing code
.NET FRAMEWORK .NET Framework BCL ASP.NET Windows Forms WPF .NET CORE .NET Core BCL UWP ASP.NET Core XAMARIN Mono BCL iOS Android OS X MODELS APP Notes: Even if we are reusing a lot across components (especially with the open sourcing last year), the reality is that each platform has its own implementation of the base libraries. Note: .NET Framework BCL and Mono BCL are the same APIs, different implementation. .NET Core “Core Library” is a similar set of APIs, but different. LIBRARIES BASE
5
.NET today – reusing code
.NET FRAMEWORK .NET CORE XAMARIN CHALLENGES Difficult to reuse skills Need to master 3+1 base class libraries Difficult to reuse code Need to target a fairly small common denominator Difficult to innovate Need implementations on each platform MODELS APP ASP.NET Windows Forms WPF UWP ASP.NET Core iOS Android OS X Notes: Even if we are reusing a lot across components (especially with the open sourcing last year), the reality is that each platform has its own implementation of the base libraries. Note: .NET Framework BCL and Mono BCL are the same APIs, different implementation. .NET Core “Core Library” is a similar set of APIs, but different. LIBRARIES BASE .NET Framework BCL .NET Core BCL Mono BCL
6
.NET tomorrow .NET Standard .NET FRAMEWORK .NET CORE XAMARIN MODELS
APP ASP.NET Windows Forms WPF UWP ASP.NET Core iOS Android OS X Notes: Even if we are reusing a lot across components (especially with the open sourcing last year), the reality is that each platform has its own implementation of the base libraries. Note: .NET Framework BCL and Mono BCL are the same APIs, different implementation. .NET Core “Core Library” is a similar set of APIs, but different. LIBRARIES BASE .NET Standard
7
.NET tomorrow .NET Standard Reuse skills
.NET FRAMEWORK .NET CORE XAMARIN BENEFITS Reuse skills Master one BCL, not a Venn diagram Reuse code Common denominator is much bigger Faster innovation Target .NET Standard & run anywhere MODELS APP ASP.NET Windows Forms WPF UWP ASP.NET Core iOS Android OS X Notes: Even if we are reusing a lot across components (especially with the open sourcing last year), the reality is that each platform has its own implementation of the base libraries. Note: .NET Framework BCL and Mono BCL are the same APIs, different implementation. .NET Core “Core Library” is a similar set of APIs, but different. LIBRARIES BASE .NET Standard
8
11/12/2018 9:56 PM What is .NET Standard? .NET Standard is a specification A set of APIs that all .NET platforms have to implement .NET Standard .NET Framework .NET Core Xamarin ~ HTML specification Browsers © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
9
.NET Standard versions 11/12/2018 9:56 PM
Che cosa significa compatibile? Significa ad esempio che in un’applicazone .NET Framework possiamo utilizzare tutte le API definite nella versione 2.0 di .NET Stadard. © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
10
Versioning in .NET Standard
11/12/2018 9:56 PM Versioning in .NET Standard Higher versions incorporate all APIs from previous versions. Projects targeting version X.Y can reference libraries & projects targeting any version between 1.0 and X.Y Concrete .NET platforms implement a specific version of .NET Standard From that platform you can reference libraries up to that version 2.0 1.6 1.3 1.0 © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
11
11/12/2018 9:56 PM .NET Standard 2.0 Has much bigger API surface Extended to cover intersection between .NET Framework and Xamarin Makes .NET Core 2.0 bigger as it implements .NET Standard 2.0 +20K More APIs than .NET Standard 1.x Can reference .NET Framework libraries Compat shim allows referencing existing .NET Framework code – without recompilation Limited to libs that use APIs that are available for .NET Standard ~70% of NuGet packages are API compatible Compat shim: l’adozione di .NET Standard ha un potenziale problema, che sicuramente alcuni di voi avranno già notato. Cosa succede se io decido di aggiornare una mia libreria, ma essa dipende ad esempio da un pacchetto NuGet esterno che non è ancora stato aggiornato a .NET Standard? Devo aspettare che tutte le librerie che uso vengano aggiornate, prima di poter lavorare sul mio codice? Questo in effetti rappresenterebbe un grosso problema all’adozione di .NET Standard. Uso il condizionale perché per fortuna non è così, o quantomeno non lo è del tutto. Qui si inserisce il Compat shim: è possibile da .NET Standard referenziare librerie .NET Framework esistenti senza ricompilazione. In pratica è una modalità “proviamo e vediamo se funziona”. Cerchiamo di capire meglio, perché detta così non sembra una cosa molto convincente. Quello che si è notato è che circa il 70% dei pacchetti NuGet esistenti sono già compatibili con .NET Standard dal punto di vista delle API utilizzate. Questa è una sorta di “best effort”. Ovviamente è necessario verificare il proprio codice per assicurarsi che tutto funzioni davvero sulle varie piattaforme, ma grazie a questo support possiamo aggiornare (o quantomeno provare ad aggiornare) le nostre librerie a .NET Standard e usare comunque pacchetti NuGet esistenti senza dover aspettare che anche questi ultimi vengano a loro volta portati su .NET Standard. © 2014 Microsoft Corporation. All rights reserved. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
12
.NET Standard and SQL Server
13
The road so far (before .NET Standard 2.0)
System.Data.SqlClient available as NuGet package for .NET Standard since v1.2 Not all platforms actually supported it (i.e., old UWP versions) Some database related classes like DataSet were missing
14
.NET Standard 2.0 SqlClient fully supported on all platforms
UWP supports it with the Fall Creators Update DataSet is available (again)
15
Demo
16
SQL Server with Linux
17
Flexible, reliable data management SQL Server on the platform of your choice
Windows Linux Support for RedHat Enterprise Linux (RHEL), Ubuntu, and SUSE Enterprise Linux (SLES) Linux and Windows Docker containers Windows Server / Windows 10 Package-based installation: Yum Install, Apt-Get, and Zypper Linux/Windows container Last but not least, customers need flexibility when it comes to the choice of platform, programming languages & data infrastructure to get from the most from their data. Why? In most IT environments, platforms, technologies and skills are as diverse as they have ever been, the data platform of the future needs to you to build intelligent applications on any data, any platform, any language on premises and in the cloud. SQL Server manages your data, across platforms, with any skills, on-premises & cloud Our goal is to meet you where you are with on any platform, anywhere with the tools and languages of your choice. SQL now has support for Windows, Linux & Docker Containers. It allows you to leverage the language of your choice for advanced analytics – R & Python.
18
SQL Operations Studio Cross-Platform SQL Server Management Tool
19
Dapper with .NET Standard
20
Classing ADO .NET approach
21
Dapper is a micro OR/M Speed Simplicity
Avoiding the ceremony of ADO.NET Speed – OR/M means overhead, a micro OR/M performance will be very close to plain ADO.NET. In my experience, data access is very often the performance bottleneck. YAGNI – OR/Ms ship with a bunch of features that require some extra work that you don’t need, shouldn’t need. OR/Ms often need a significant amount of configuration and setup, especially if you don’t (or can’t) follow conventions. With a Micro OR/M it’s pretty much Install-Package and you’re ready to go. ADO.NET is (was) pretty great, but it shipped with .NET 1.0, that’s like 15 years ago In technology terms, it’s as old as the moon. There is so much ceremony with ADO.NET that it’s just intolerable in many (not all) cases
22
How it works Sits right on top of ADO.NET
Extension methods for IDbConnection We need to write SQL Compatible with .NET Standard 1.3
23
Demo
24
References
25
Thank you. DotNetToscana Dotnettoscana.org @dotnettoscana
Marco Minerva Microsoft MVP – Windows Development DotNetToscana Dotnettoscana.org @dotnettoscana
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.