Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/.net-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100
dotnet-version: 10.0.100

- name: Tests
run: dotnet test EntityFrameworkCore.SqlServer.SimpleBulks.Tests/EntityFrameworkCore.SqlServer.SimpleBulks.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100
dotnet-version: 10.0.100

- name: Tests
run: dotnet test EntityFrameworkCore.SqlServer.SimpleBulks.Tests/EntityFrameworkCore.SqlServer.SimpleBulks.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.net-test-connection-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100
dotnet-version: 10.0.100

- name: Tests
run: dotnet test EntityFrameworkCore.SqlServer.SimpleBulks.Tests/EntityFrameworkCore.SqlServer.SimpleBulks.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100
dotnet-version: 10.0.100

- name: Tests
run: dotnet test EntityFrameworkCore.SqlServer.SimpleBulks.Tests/EntityFrameworkCore.SqlServer.SimpleBulks.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/.net-test-dbcontext-extensions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 8.0.100
dotnet-version: 10.0.100

- name: Tests
run: dotnet test EntityFrameworkCore.SqlServer.SimpleBulks.Tests/EntityFrameworkCore.SqlServer.SimpleBulks.Tests.csproj /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura
Expand Down
81 changes: 52 additions & 29 deletions src/DbContextExtensionsExamples/DemoDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DbContextExtensionsExamples;

Expand All @@ -17,12 +15,22 @@ public class DemoDbContext : DbContext

public DbSet<ConfigurationEntry> ConfigurationEntries { get; set; }

public DbSet<Order> Orders { get; set; }

public DbSet<Blog> Blogs { get; set; }

public DbSet<RssBlog> RssBlogs { get; set; }

public DbSet<ComplexTypeOrder> ComplexTypeOrders { get; set; }

public DbSet<OwnedTypeOrder> OwnedTypeOrders { get; set; }

public DbSet<ComplexOwnedTypeOrder> ComplexOwnedTypeOrders { get; set; }

public DbSet<JsonComplexTypeOrder> JsonComplexTypeOrders { get; set; }

public DbSet<JsonOwnedTypeOrder> JsonOwnedTypeOrders { get; set; }

public DbSet<JsonComplexOwnedTypeOrder> JsonComplexOwnedTypeOrders { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(_connectionString);
Expand All @@ -42,35 +50,50 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<ConfigurationEntry>().Property(x => x.Id).HasColumnName("Id1");
modelBuilder.Entity<ConfigurationEntry>().Property(x => x.SeasonAsString).HasConversion(v => v.ToString(), v => (Season)Enum.Parse(typeof(Season), v));

modelBuilder.Entity<JsonComplexTypeOrder>().ComplexProperty(x => x.ShippingAddress, x =>
{
x.ToJson();
//x.ToJson("xxx").HasColumnType("json");
x.ComplexProperty(y => y.Location, y =>
{
y.HasJsonPropertyName("xxx");
});
});

modelBuilder.Entity<JsonOwnedTypeOrder>().OwnsOne(x => x.ShippingAddress, x =>
{
x.ToJson();
//x.ToJson("xxx").HasColumnType("json");
x.OwnsOne(y => y.Location, y =>
{
y.HasJsonPropertyName("xxx");
});
});

modelBuilder.Entity<JsonComplexOwnedTypeOrder>().ComplexProperty(x => x.ComplexShippingAddress, x =>
{
x.ToJson();
//x.ToJson("xxx").HasColumnType("json");
x.ComplexProperty(y => y.Location, y =>
{
y.HasJsonPropertyName("xxx");
});
});

modelBuilder.Entity<JsonComplexOwnedTypeOrder>().OwnsOne(x => x.OwnedShippingAddress, x =>
{
x.ToJson();
//x.ToJson("xxx").HasColumnType("json");
x.OwnsOne(y => y.Location, y =>
{
y.HasJsonPropertyName("xxx");
});
});

base.OnModelCreating(modelBuilder);
}
}

public class Order
{
public int Id { get; set; }

[Required]
public Address ShippingAddress { get; set; }
}

[ComplexType]
public class Address
{
public string Street { get; set; }

[Required]
public Location Location { get; set; }
}

[ComplexType]
public class Location
{
public double Lat { get; set; }

public double Lng { get; set; }
}

public class Blog
{
public int BlogId { get; set; }
Expand Down
25 changes: 25 additions & 0 deletions src/DbContextExtensionsExamples/Entities/ComplexOwnedTypeOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.ComponentModel.DataAnnotations;

namespace DbContextExtensionsExamples.Entities;

public class ComplexOwnedTypeOrder
{
public int Id { get; set; }

[Required]
public ComplexTypeAddress ComplexShippingAddress { get; set; }

[Required]
public OwnedTypeAddress OwnedShippingAddress { get; set; }
}

public class JsonComplexOwnedTypeOrder
{
public int Id { get; set; }

[Required]
public ComplexTypeAddress ComplexShippingAddress { get; set; }

[Required]
public OwnedTypeAddress OwnedShippingAddress { get; set; }
}
36 changes: 36 additions & 0 deletions src/DbContextExtensionsExamples/Entities/ComplexTypeOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace DbContextExtensionsExamples.Entities;

public class ComplexTypeOrder
{
public int Id { get; set; }

[Required]
public ComplexTypeAddress ShippingAddress { get; set; }
}

[ComplexType]
public class ComplexTypeAddress
{
public string Street { get; set; }

public ComplexTypeLocation Location { get; set; }
}

[ComplexType]
public class ComplexTypeLocation
{
public double Lat { get; set; }

public double Lng { get; set; }
}

public class JsonComplexTypeOrder
{
public int Id { get; set; }

[Required]
public ComplexTypeAddress ShippingAddress { get; set; }
}
37 changes: 37 additions & 0 deletions src/DbContextExtensionsExamples/Entities/OwnedTypeOrder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;

namespace DbContextExtensionsExamples.Entities;

public class OwnedTypeOrder
{
public int Id { get; set; }

[Required]
public OwnedTypeAddress ShippingAddress { get; set; }
}

[Owned]
public class OwnedTypeAddress
{
public string Street { get; set; }

[Required]
public OwnedTypeLocation Location { get; set; }
}

[Owned]
public class OwnedTypeLocation
{
public double Lat { get; set; }

public double Lng { get; set; }
}

public class JsonOwnedTypeOrder
{
public int Id { get; set; }

[Required]
public OwnedTypeAddress ShippingAddress { get; set; }
}

This file was deleted.

Loading
Loading