This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Based on ASP.NET Core's ConnectionBuilder | |
| using System; | |
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| var pipeline = new Pipeline() | |
| .Use((context, next) => | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static class DbExtensions | |
| { | |
| public static IDbCommand CreateCommand(this IDbConnection connection, FormattableString sql) | |
| { | |
| var command = connection.CreateCommand(); | |
| var substitutions = new object[sql.ArgumentCount]; | |
| for (var i = 0; i < sql.ArgumentCount; i++) | |
| { | |
| var parameter = command.CreateParameter(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Threading.Tasks; | |
| using Microsoft.AspNetCore.Mvc; | |
| using Microsoft.AspNetCore.Mvc.RazorPages; | |
| using Microsoft.EntityFrameworkCore; | |
| using Todo.Data; | |
| using Todo.Models; | |
| namespace Todo.Pages |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @page | |
| @using System.Linq | |
| @using Todo.Pages | |
| @model IndexModel | |
| @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | |
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="utf-8"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <form method="POST"> | |
| <button asp-page-handler="create"></button> | |
| </form> | |
| public async Task<IActionResult> OnPostCreateAsync() | |
| { | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.AspNetCore.Mvc.RazorPages; | |
| namespace Todo.Pages | |
| { | |
| public class IndexModel : PageModel | |
| { | |
| public void OnGet() | |
| { | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System.IO; | |
| using Microsoft.AspNetCore.Builder; | |
| using Microsoft.AspNetCore.Hosting; | |
| using Microsoft.EntityFrameworkCore; | |
| using Microsoft.Extensions.DependencyInjection; | |
| using Microsoft.Extensions.FileProviders; | |
| using Todo.Data; | |
| namespace Todo | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| app.Run(async (context) => | |
| { | |
| await context.Response.WriteAsync("Hello World!"); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Microsoft.EntityFrameworkCore; | |
| using Todo.Models; | |
| namespace Todo.Data | |
| { | |
| public class TodoDbContext : DbContext | |
| { | |
| public TodoDbContext(DbContextOptions<TodoDbContext> options) : base(options) | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Todo.Models | |
| { | |
| public class TodoItem | |
| { | |
| public int Id { get; set; } | |
| public string Description { get; set; } | |
| public bool IsCompleted { get; set; } | |
| } | |
| } |
NewerOlder