You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+73-9
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Please note that the "One-To-Many Relatioships" and "Complex Custom Handling" po
23
23
24
24
To run the "Basic Samples", related to the first article "Getting Started with Dapper .NET", just run
25
25
26
-
```dotnet run -f net48```
26
+
```dotnet run -f net5.0```
27
27
28
28
from
29
29
@@ -35,36 +35,37 @@ folder. To run advanced samples you have to move into
35
35
36
36
and then from here you can just run
37
37
38
-
```dotnet run -f net48```
38
+
```dotnet run -f net5.0```
39
39
40
40
to run ALL samples or
41
41
42
-
```dotnet run -f net48 "Sample Name"```
42
+
```dotnet run -f net5.0 "Sample Name"```
43
43
44
44
to run that specific sample. Eg:
45
45
46
-
```dotnet run -f net48 "Multiple Executions"```
46
+
```dotnet run -f net5.0 "Multiple Executions"```
47
47
48
48
to run only the "Multiple Execution" sample.
49
49
50
50
To have a list of all advanced samples available run:
51
51
52
-
```dotnet run -f net48 -help```
52
+
```dotnet run -f net5.0 -help```
53
53
54
54
## Notes
55
55
56
56
### .NET Version
57
57
58
-
Samples are done using [.NET Core 3.0](https://www.microsoft.com/net/download/windows) and [.NET Framework 4.8](https://www.microsoft.com/net/download/windows): make sure you have them installed it on your machine.
58
+
Samples are done using [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0), and [.NET Framework 4.8](https://www.microsoft.com/net/download/windows): make sure you have them installed it on your machine
59
59
60
60
The project supports multiple targets:
61
61
62
+
* net5.0
63
+
* netcoreapp3.1
62
64
* net48
63
-
* netcoreapp3.0
64
65
65
-
To execute the application targeting one specifc framework, just use the `-f` option when running the console app:
66
+
To execute the application targeting one specific framework, just use the `-f` option when running the console app:
66
67
67
-
```dotnet run -f net48```
68
+
```dotnet run -f net5.0```
68
69
69
70
more info on the `-f` option here:
70
71
@@ -80,3 +81,66 @@ If you are looking for samples supporting older version, take a look at the prev
80
81
81
82
Samples also use SQL Server as database server. If you don't have a Windows machine, you can use the Docker version: [SQL Server 2017](https://www.microsoft.com/en-us/sql-server/sql-server-2017).
82
83
SQL Server database file is attached automatically using the `LocalDB/MSSQLServer` instance. If you prefer to use a non-local instance, make sure you change the connection string accordingly, and attach the database file to your instance.
84
+
85
+
86
+
### OPENJSON and 2K limit
87
+
88
+
In Azure SQL and SQL Server, when JSON is returned as part of a SELECT ... FOR JSON, if the resulting JSON is bigger than 2K, it will be chunked and thus it must be put back together on the client. Using SQL Server Management Studio you will not see any of this as it automatically do this for you, but if you using .NET you have to do it yourself as described here: [User FOR JSON output in a C# client app](https://docs.microsoft.com/en-us/sql/relational-databases/json/use-for-json-output-in-sql-server-and-in-client-apps-sql-server). This is actually true for other languages and not only for C#.
89
+
A bit more detail on this behavior here: [SQL Server JSON result separated in multiple rows](https://stackoverflow.com/questions/41880611/sql-server-json-result-separated-in-multiple-rows/41915103#41915103).
90
+
91
+
The samples have been updated to show how to properly manage this behavior, as also described in this post by MVP Hasan Savran: [JSON Challenges for DEVS in SQL Server](https://h-savran.blogspot.com/2020/04/challenges-with-returning-data-as-json.html).
92
+
93
+
The "trick" is to wrap FOR JSON in another SELECT or assign it to a variable:
94
+
95
+
```sql
96
+
SELECT (
97
+
SELECT
98
+
u.Id,
99
+
u.FirstName,
100
+
u.LastName,
101
+
u.EMailAddressAS'EmailAddress',
102
+
(SELECT JSON_QUERY(REPLACE(REPLACE((SELECT [Tag] FROM dbo.[UserTags] t WHEREt.UserId=u.Id FOR JSON PATH), '{"Tag":', ''), '}', ''))) AS Tags,
103
+
JSON_QUERY((SELECT r.[value] as [RoleName] FROM dbo.[Users] ur CROSS APPLY STRING_SPLIT(Roles, ',') AS r WHEREur.Id=u.Id FOR JSON AUTO)) AS Roles,
104
+
u.Notes,
105
+
c.IdAS'Company.Id',
106
+
c.CompanyNameAS'Company.CompanyName',
107
+
c.StreetAS'Company.Address.Street',
108
+
c.CityAS'Company.Address.City',
109
+
c.[State] AS'Company.Address.State',
110
+
c.CountryAS'Company.Address.Country',
111
+
JSON_QUERY(u.CustomData, '$.Preferences') AS Preferences
112
+
FROM
113
+
dbo.[Users] u
114
+
LEFT JOIN
115
+
dbo.[Companies] c ONu.CompanyId=c.Id
116
+
WHERE
117
+
u.id= @id
118
+
FOR JSON PATH, WITHOUT_ARRAY_WRAPPER
119
+
) as [object]
120
+
```
121
+
122
+
## Learn More
123
+
124
+
If you want to learn more on how to create modern application with SQL Server and Azure SQL, the following book is for you:
125
+
126
+
[](https://www.apress.com/it/book/9781484263693)
127
+
128
+
### About This Book
129
+
130
+
Here is the expert-level, insider guidance you need on using Azure SQL Database as your back-end data store. This book highlights best practices in everything ranging from full-stack projects to mobile applications to critical, back-end APIs. The book provides instruction on accessing your data from any language and platform. And you learn how to push processing-intensive work into the database engine to be near the data and avoid undue networking traffic. Azure SQL is explained from a developer's point of view, helping you master its feature set and create applications that perform well and delight users.
131
+
132
+
Core to the book is showing you how Azure SQL Database provides relational and post-relational support so that any workload can be managed with easy accessibility from any platform and any language. You will learn about features ranging from lock-free tables to columnstore indexes, and about support for data formats ranging from JSON and key-values to the nodes and edges in the graph database paradigm. Reading this book prepares you to deal with almost all data management challenges, allowing you to create lean and specialized solutions having the elasticity and scalability that are needed in the modern world.
133
+
134
+
### What You Will Learn
135
+
136
+
Master Azure SQL Database in your development projects from design to the CI/CD pipeline
137
+
Access your data from any programming language and platform
138
+
Combine key-value, JSON, and relational data in the same database
139
+
Push data-intensive compute work into the database for improved efficiency
140
+
Delight your customers by detecting and improving poorly performing queries
141
+
Enhance performance through features such as columnstore indexes and lock-free tables
142
+
Build confidence in your mastery of Azure SQL Database's feature set
143
+
144
+
145
+
### Who This Book Is For
146
+
Developers of applications and APIs that benefit from cloud database support, developers who wish to master their tools (including Azure SQL Database, and those who want their applications to be known for speedy performance and the elegance of their code
0 commit comments