Skip to content

Instantly share code, notes, and snippets.

Derek Comartin dcomartin

View GitHub Profile
View dbContext.cs
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
.Query<BlogPostsCount>().ToView("View_BlogPostCounts")
.Property(v => v.BlogName).HasColumnName("Name");
}
View model.cs
public class BlogPostsCount
{
public string BlogName { get; set; }
public int PostCount { get; set; }
}
View view.cs
db.Database.ExecuteSqlCommand(
@"CREATE VIEW View_BlogPostCounts AS
SELECT b.Name, Count(p.PostId) as PostCount
FROM Blogs b
JOIN Posts p on p.BlogId = b.BlogId
GROUP BY b.Name");
View ShipmentReadWrite.cs
public class ShipmentCommand
{
private DateTime? _delivery;
private string _proofOfDelivery;
public ShipmentCommand(Guid shipmentID)
{
// Load current state
}
View Shipment.cs
public class Shipment
{
private DateTime? _delivery;
private string _proofOfDelivery;
public Shipment(Guid shipmentID)
{
// Load current state
}
View startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
View app.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<UserSecretsId>4ea3e45e-51fe-4a42-9223-d2aa9ac25709</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
View redisname.cs
services.AddSignalR().AddRedis(options =>
{
options.Configuration.ClientName = "SignalR";
});
View redis.cs
// For Microsoft.AspNetCore.SignalR.Redis
services.AddSignalR().AddRedis();
// For Microsoft.AspNetCore.SignalR.StackExchangeRedis
services.AddSignalR().AddStackExchangeRedis();
View startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication()
.AddJwtBearer(options => {
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var accessToken = context.Request.Query["access_token"];
if (string.IsNullOrEmpty(accessToken) == false) {
You can’t perform that action at this time.