mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
Merge pull request #59 from JocaPC/json
Added .Net Todo REST API sample
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
TodoRestWebAPI.xproj.user
|
||||||
|
.vs/*
|
||||||
|
bin/*
|
||||||
|
obj/*
|
||||||
|
*.sln
|
||||||
|
*.log
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
using Belgrade.SqlClient;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace TodoApp.Controllers
|
||||||
|
{
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
public class TodoController : Controller
|
||||||
|
{
|
||||||
|
private readonly IQueryPipe SqlPipe;
|
||||||
|
private readonly ICommand SqlCommand;
|
||||||
|
|
||||||
|
public TodoController(ICommand sqlCommand, IQueryPipe sqlPipe)
|
||||||
|
{
|
||||||
|
this.SqlCommand = sqlCommand;
|
||||||
|
this.SqlPipe = sqlPipe;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/Todo
|
||||||
|
[HttpGet]
|
||||||
|
public async Task Get()
|
||||||
|
{
|
||||||
|
await SqlPipe.Stream("select * from Todo FOR JSON PATH", Response.Body, "[]");
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET api/Todo/5
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public async Task Get(int id)
|
||||||
|
{
|
||||||
|
var cmd = new SqlCommand("select * from Todo where Id = @id FOR JSON PATH, WITHOUT_ARRAY_WRAPPER");
|
||||||
|
cmd.Parameters.AddWithValue("id", id);
|
||||||
|
await SqlPipe.Stream(cmd, Response.Body, "{}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST api/Todo
|
||||||
|
[HttpPost]
|
||||||
|
public async Task Post()
|
||||||
|
{
|
||||||
|
string todo = new StreamReader(Request.Body).ReadToEnd();
|
||||||
|
var cmd = new SqlCommand(
|
||||||
|
@"insert into Todo
|
||||||
|
select *
|
||||||
|
from OPENJSON(@todo)
|
||||||
|
WITH( Title nvarchar(30), Description nvarchar(4000), Completed bit, TargetDate datetime2)");
|
||||||
|
cmd.Parameters.AddWithValue("todo", todo);
|
||||||
|
await SqlCommand.ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PATCH api/Todo
|
||||||
|
[HttpPatch]
|
||||||
|
public async Task Patch(int id)
|
||||||
|
{
|
||||||
|
string todo = new StreamReader(Request.Body).ReadToEnd();
|
||||||
|
var cmd = new SqlCommand(
|
||||||
|
@"update Todo
|
||||||
|
set Title = ISNULL(json.Title, Title), Description = ISNULL(json.Description, Description),
|
||||||
|
Completed = ISNULL(json.Completed, Completed), TargetDate = ISNULL(json.TargetDate, TargetDate)
|
||||||
|
from OPENJSON(@todo)
|
||||||
|
WITH( Title nvarchar(30), Description nvarchar(4000),
|
||||||
|
Completed bit, TargetDate datetime2) AS json
|
||||||
|
where Id = @id");
|
||||||
|
cmd.Parameters.AddWithValue("id", id);
|
||||||
|
cmd.Parameters.AddWithValue("todo", todo);
|
||||||
|
await SqlCommand.ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT api/Todo/5
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public async Task Put(int id)
|
||||||
|
{
|
||||||
|
string todo = new StreamReader(Request.Body).ReadToEnd();
|
||||||
|
var cmd = new SqlCommand(
|
||||||
|
@"update Todo
|
||||||
|
set Title = json.Title, Description = json.Description,
|
||||||
|
Completed = json.completed, TargetDate = json.TargetDate
|
||||||
|
from OPENJSON( @todo )
|
||||||
|
WITH( Title nvarchar(30), Description nvarchar(4000),
|
||||||
|
Completed bit, TargetDate datetime2) AS json
|
||||||
|
where Id = @id");
|
||||||
|
cmd.Parameters.AddWithValue("id", id);
|
||||||
|
cmd.Parameters.AddWithValue("todo", todo);
|
||||||
|
await SqlCommand.ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE api/Todo/5
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public async Task Delete(int id)
|
||||||
|
{
|
||||||
|
var cmd = new SqlCommand(@"delete Todo where Id = @id");
|
||||||
|
cmd.Parameters.AddWithValue("id", id);
|
||||||
|
await SqlCommand.ExecuteNonQuery(cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
|
||||||
|
namespace TodoApp
|
||||||
|
{
|
||||||
|
public class Program
|
||||||
|
{
|
||||||
|
public static void Main(string[] args)
|
||||||
|
{
|
||||||
|
var host = new WebHostBuilder()
|
||||||
|
.UseKestrel()
|
||||||
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
|
.UseIISIntegration()
|
||||||
|
.UseStartup<Startup>()
|
||||||
|
.Build();
|
||||||
|
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,184 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<title>Welcome to ASP.NET Core Web API REST Service</title>
|
||||||
|
<style>
|
||||||
|
html {
|
||||||
|
background: #f1f1f1;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #fff;
|
||||||
|
color: #505050;
|
||||||
|
font: 14px 'Segoe UI', tahoma, arial, helvetica, sans-serif;
|
||||||
|
margin: 1%;
|
||||||
|
min-height: 95.5%;
|
||||||
|
border: 1px solid silver;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header h1 {
|
||||||
|
font-size: 44px;
|
||||||
|
font-weight: normal;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px 30px 10px 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header span {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0 30px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#header p {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #fff;
|
||||||
|
background: #007acc;
|
||||||
|
padding: 0 30px;
|
||||||
|
line-height: 50px;
|
||||||
|
margin-top: 25px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#header p a {
|
||||||
|
color: #fff;
|
||||||
|
text-decoration: underline;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-right: 35px;
|
||||||
|
background: no-repeat right bottom url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAWCAMAAAAcqPc3AAAANlBMVEUAAAAAeswfitI9mthXp91us+KCvuaTx+mjz+2x1u+83PLH4vTR5/ba7Pjj8Pns9fv1+v3////wy3dWAAAAAXRSTlMAQObYZgAAAHxJREFUeNp9kVcSwCAIRMHUYoH7XzaxOxJ9P8oyQ1uIqNPwh3s2aLmIM2YtqrLcQIeQEylhuCeUOlhgve5yoBCfWmlnlgkN4H8ykbpaE7gR03AbUHiwoOxUH9Xp+ubd41p1HF3mBPrfC87BHeTdaB3ceeKL9HGpcvX9zu6+DdMWT9KQPvYAAAAASUVORK5CYII=);
|
||||||
|
}
|
||||||
|
|
||||||
|
#main {
|
||||||
|
padding: 5px 30px;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
width: 21.7%;
|
||||||
|
float: left;
|
||||||
|
margin: 0 0 0 4%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section h2 {
|
||||||
|
font-size: 13px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
margin: 0;
|
||||||
|
border-bottom: 1px solid silver;
|
||||||
|
padding-bottom: 12px;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section.first {
|
||||||
|
margin-left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section.first h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
text-transform: none;
|
||||||
|
margin-bottom: 25px;
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section.first li {
|
||||||
|
border-top: 1px solid silver;
|
||||||
|
padding: 8px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section.last {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
li {
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: #267cb2;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer {
|
||||||
|
clear: both;
|
||||||
|
padding-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#footer p {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="header">
|
||||||
|
<h1>Welcome to ASP.NET Core REST API Project</h1>
|
||||||
|
<span>
|
||||||
|
In this example you can see how to easily create REST API with CRUD operations using ASP.NET Core Framework and
|
||||||
|
built-in JSON functionalities in SQL Server 2016 and Azure SQL Database.
|
||||||
|
</span>
|
||||||
|
<p>You can find detailed explanation in <a href="http://www.codeproject.com/Articles/1106622/Building-REST-services-with-ASP-NET-Core-Web-API-a">Code Project</a> article.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="main">
|
||||||
|
<div class="section first">
|
||||||
|
<h2>This application consists of:</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Simple database with one Todo table.</li>
|
||||||
|
<li>Simple Controller that implements CRUD operations on Todo table.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="section">
|
||||||
|
<h2>Setup and configure</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Create new database on SQL Server 2016 or Azure SQL.</li>
|
||||||
|
<li>If you are using Azure SQL make sure that firewall rules in Azure enable you to make connections between your host and Azure SQL database.</li>
|
||||||
|
<li>Execute <a href="setup/setup.sql" target="_blank">setup.sql</a> script to create Todo table and populate it with sample data.</li>
|
||||||
|
<li>Open .xproj file in Visual Studio 2015 and set connection string in <a href="Startup.cs" target="_blank">Startup.cs</a> file:
|
||||||
|
<code>
|
||||||
|
|
||||||
|
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
|
||||||
|
const string ConnString = "Server=SERVERNAME.database.windows.net;Database=DATABASENAME;User Id=USERNAME;Password=PASSWORD";
|
||||||
|
|
||||||
|
</code>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="section last">
|
||||||
|
<h2>Run</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Run the project and see results returned from /api/Todo URL.</li>
|
||||||
|
<li>Open /api/Todo/1 URL to try GET method that returns single Todo item.</li>
|
||||||
|
<li>Use some tool that send POST, PUT, PATCH, or DELETE requests to web server (e.g. Chrome Poster) to try other methods.</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
<p>We would love to hear your <a href="mailto:sqlserversamples@microsoft.com">feedback</a>!</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"iisSettings": {
|
||||||
|
"windowsAuthentication": false,
|
||||||
|
"anonymousAuthentication": true,
|
||||||
|
"iisExpress": {
|
||||||
|
"applicationUrl": "http://localhost:15194/",
|
||||||
|
"sslPort": 0
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"profiles": {
|
||||||
|
"IIS Express": {
|
||||||
|
"commandName": "IISExpress",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "api/Todo",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"TodoApp": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"launchBrowser": true,
|
||||||
|
"launchUrl": "http://localhost:5000/api/Todo",
|
||||||
|
"environmentVariables": {
|
||||||
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# ASP.NET Core REST Web API that uses SQL/JSON functionalites
|
||||||
|
|
||||||
|
This project contains an example implementation of ASP.NET Core REST API with CRUD operations on a simple Todo table. You can learn how to build REST API on the existing database schema using new JSON functionalities that are available in SQL Server 2016 (or higher) and Azure SQL Database.
|
||||||
|
|
||||||
|
### Contents
|
||||||
|
|
||||||
|
[About this sample](#about-this-sample)<br/>
|
||||||
|
[Before you begin](#before-you-begin)<br/>
|
||||||
|
[Run this sample](#run-this-sample)<br/>
|
||||||
|
[Sample details](#sample-details)<br/>
|
||||||
|
[Disclaimers](#disclaimers)<br/>
|
||||||
|
[Related links](#related-links)<br/>
|
||||||
|
|
||||||
|
<a name=about-this-sample></a>
|
||||||
|
|
||||||
|
## About this sample
|
||||||
|
|
||||||
|
- **Applies to:** SQL Server 2016 (or higher), Azure SQL Database
|
||||||
|
- **Key features:** JSON Functions in SQL Server 2016/Azure SQL Database - FOR JSON and OPENJSON
|
||||||
|
- **Programming Language:** C#
|
||||||
|
- **Authors:** Jovan Popovic
|
||||||
|
|
||||||
|
<a name=before-you-begin></a>
|
||||||
|
|
||||||
|
## Before you begin
|
||||||
|
|
||||||
|
To run this sample, you need the following prerequisites.
|
||||||
|
|
||||||
|
**Software prerequisites:**
|
||||||
|
|
||||||
|
1. SQL Server 2016 (or higher) or an Azure SQL Database
|
||||||
|
2. Visual Studio 2015 (or higher) with the ASP.NET Core RC2 (or higher)
|
||||||
|
|
||||||
|
**Azure prerequisites:**
|
||||||
|
|
||||||
|
1. Permission to create an Azure SQL Database
|
||||||
|
|
||||||
|
<a name=run-this-sample></a>
|
||||||
|
|
||||||
|
## Run this sample
|
||||||
|
|
||||||
|
1. From SQL Server Management Studio or Sql Server Data Tools connect to your SQL Server 2016 or Azure SQL database and execute setup.sql script that will create and populate Todo table in the database.
|
||||||
|
|
||||||
|
2. From Visual Studio, open the **TodoApp.xproj** file from the root directory,
|
||||||
|
|
||||||
|
3. Locate Startup.cs file in the project, change connection string in ConfigureServices method to reference your database, and build solution using Ctrl+Shift+B, right-click on project + Build, or Build/Build Solution from menu.
|
||||||
|
|
||||||
|
4. Run sample app using F5 or Ctrl+F5,
|
||||||
|
4.1. Open /api/Todo Url to get all Todo items as a JSON array,
|
||||||
|
4.2. Open /api/Todo/1 Url to get details about a single Todo item with id 1,
|
||||||
|
4.3. Send POST, PUT, PATCH, or DELETE Http requests to update content of Todo table.
|
||||||
|
|
||||||
|
<a name=sample-details></a>
|
||||||
|
|
||||||
|
## Sample details
|
||||||
|
|
||||||
|
This sample application shows how to create simple REST API service that performs CRUD operations on a simple Todo table.
|
||||||
|
ASP.NET Core Web API is used to implement REST Service in the example.
|
||||||
|
Service uses built-in JSON functionalities that are available in SQL Server 2016 and Azure SQL Database.
|
||||||
|
|
||||||
|
<a name=disclaimers></a>
|
||||||
|
|
||||||
|
## Disclaimers
|
||||||
|
The code included in this sample is not intended demonstrate some general guidances and arhitectural patterns for web development. It contains minimal code required to create REST API, and it does not use some patterns such as Repository. Sample uses built-in ASP.NET Core Dependency Injection mechanism; however, this is not prerequisite.
|
||||||
|
You can easily modify this code to fit the architecture of your application.
|
||||||
|
|
||||||
|
<a name=related-links></a>
|
||||||
|
|
||||||
|
## Related Links
|
||||||
|
|
||||||
|
For more information, see this [article](http://www.codeproject.com/Articles/1106622/Building-Web-API-REST-services-on-Azure-SQL-Databa).
|
||||||
|
|
||||||
|
## License
|
||||||
|
These samples and templates are all licensed under the MIT license. See the license.txt file in the root.
|
||||||
|
|
||||||
|
## Questions
|
||||||
|
Email questions to: sqlserversamples@microsoft.com.
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
using Belgrade.SqlClient;
|
||||||
|
using Belgrade.SqlClient.SqlDb;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
|
||||||
|
namespace TodoApp
|
||||||
|
{
|
||||||
|
public class Startup
|
||||||
|
{
|
||||||
|
public Startup(IHostingEnvironment env)
|
||||||
|
{
|
||||||
|
var builder = new ConfigurationBuilder()
|
||||||
|
.SetBasePath(env.ContentRootPath)
|
||||||
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
||||||
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
|
||||||
|
.AddEnvironmentVariables();
|
||||||
|
Configuration = builder.Build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IConfigurationRoot Configuration { get; }
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
{
|
||||||
|
const string ConnString = "Server=SERVERNAME.database.windows.net;Database=DATABASENAME;User Id=USERNAME;Password=PASSWORD";
|
||||||
|
|
||||||
|
services.AddTransient<IQueryPipe>( _=> new QueryPipe(new SqlConnection(ConnString)));
|
||||||
|
services.AddTransient<ICommand>( _=> new Command(new SqlConnection(ConnString)));
|
||||||
|
|
||||||
|
// Add framework services.
|
||||||
|
services.AddMvc();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||||
|
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||||
|
{
|
||||||
|
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||||
|
loggerFactory.AddDebug();
|
||||||
|
|
||||||
|
app.UseMvc();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
|
||||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
<PropertyGroup Label="Globals">
|
||||||
|
<ProjectGuid>c8014cba-1952-414a-b78e-f60f9e5c5625</ProjectGuid>
|
||||||
|
<RootNamespace>TodoApp</RootNamespace>
|
||||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
|
||||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
|
||||||
|
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"IncludeScopes": false,
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Debug",
|
||||||
|
"System": "Information",
|
||||||
|
"Microsoft": "Information"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"dependencies": {
|
||||||
|
"Belgrade.Sql.Client": "0.1.0",
|
||||||
|
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
|
||||||
|
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
|
||||||
|
"System.Data.SqlClient": "4.1.0-rc2-24027"
|
||||||
|
},
|
||||||
|
|
||||||
|
"tools": {
|
||||||
|
"Microsoft.AspNetCore.Server.IISIntegration.Tools": {
|
||||||
|
"version": "1.0.0-preview1-final",
|
||||||
|
"imports": "portable-net45+win8+dnxcore50"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
"frameworks": {
|
||||||
|
"net46": { }
|
||||||
|
},
|
||||||
|
|
||||||
|
"buildOptions": {
|
||||||
|
"emitEntryPoint": true,
|
||||||
|
"preserveCompilationContext": true
|
||||||
|
},
|
||||||
|
|
||||||
|
"publishOptions": {
|
||||||
|
"include": [
|
||||||
|
"wwwroot",
|
||||||
|
"Views",
|
||||||
|
"appsettings.json",
|
||||||
|
"web.config"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
|
"scripts": {
|
||||||
|
"postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
|
||||||
|
}
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
|||||||
|
DROP TABLE IF EXISTS Todo
|
||||||
|
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE TABLE Todo (
|
||||||
|
Id int IDENTITY PRIMARY KEY,
|
||||||
|
Title nvarchar(30) NOT NULL,
|
||||||
|
Description nvarchar(4000),
|
||||||
|
Completed bit,
|
||||||
|
TargetDate datetime2
|
||||||
|
)
|
||||||
|
|
||||||
|
GO
|
||||||
|
|
||||||
|
INSERT INTO Todo (Title, Description, Completed, TargetDate)
|
||||||
|
VALUES
|
||||||
|
('Install SQL Server 2016','Install RTM version of SQL Server 2016', 0, '2016-06-01'),
|
||||||
|
('Get new samples','Go to github and download new samples', 0, '2016-06-02'),
|
||||||
|
('Try new samples','Install new Management Studio to try samples', 0, '2016-06-02')
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Configure your application settings in appsettings.json. Learn more at http://go.microsoft.com/fwlink/?LinkId=786380
|
||||||
|
-->
|
||||||
|
|
||||||
|
<system.webServer>
|
||||||
|
<handlers>
|
||||||
|
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified"/>
|
||||||
|
</handlers>
|
||||||
|
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false"/>
|
||||||
|
</system.webServer>
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user