Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/KorzhCom/EasyData
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergiy Korzh committed Nov 27, 2023
2 parents 0395d1b + 7ff2bcc commit 4393eea
Show file tree
Hide file tree
Showing 41 changed files with 528 additions and 65 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/netcore-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
dotnet-version: '8.0.x'
- name: Setup .NET 6
uses: actions/setup-dotnet@v1
with:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net5.0;net6.0;net8.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<RootNamespace>EasyData.AspNetCore</RootNamespace>
<Description>ASP.NET Core classes for EasyData library.</Description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ await WriteOkJsonResponseAsync(HttpContext, async (jsonWriter, cancellationToken

/// <summary>
/// Writes the model's content to the JsonWriter.
/// Can be overriden in the derived classes to write some extra data to the response for GetModel request .
/// Can be overridden in the derived classes to write some extra data to the response for GetModel request .
/// </summary>
/// <param name="jsonWriter">An instance of JsonWriter.</param>
/// <param name="model">The data model.</param>
Expand Down
2 changes: 1 addition & 1 deletion easydata.net/src/EasyData.Core/EasyData.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net6.0;net8.0</TargetFrameworks>
<RootNamespace>EasyData</RootNamespace>
<Description>Basic classes of EasyData library.</Description>
<DocumentationFile>EasyData.Core.xml</DocumentationFile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;netstandard2.1;net5.0;net6.0;net8.0</TargetFrameworks>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<RootNamespace>EasyData.EntityFrameworkCore</RootNamespace>
<Description>Entity Framework Core classes for EasyData library.</Description>
Expand All @@ -19,24 +19,24 @@
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.0.0" />
<Compile Remove="EfCore2Extensions.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net5.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.0" />
<Compile Remove="EfCore2Extensions.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net6.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0" />
<Compile Remove="EfCore2Extensions.cs" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net8.0' ">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0'">
<Compile Remove="Extensions\EfCore2Extensions.cs" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\EasyData.Core\EasyData.Core.csproj" />
</ItemGroup>

</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static string GetDbTableName(this IEntityType entityType)
public static string GetDbColumnName(this IProperty property)
{
#if NET
var entityType = property.DeclaringEntityType;
var entityType = property.DeclaringType as IEntityType;
if (entityType == null) return null;
var tableName = entityType.GetDbTableName();
if (tableName == null) return null;
Expand Down
6 changes: 3 additions & 3 deletions easydata.net/version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"assemblyVersion": "1.4.18.1",
"packageVersion": "1.4.18",
"assetVersion": "01_04_18"
"assemblyVersion": "1.4.19.1",
"packageVersion": "1.4.19",
"assetVersion": "01_04_19"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</ItemGroup>

<ItemGroup>
<None Update="App_Data\EqDemoData.zip">
<None Update="App_Data\EdDemoData.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
Expand Down
Binary file not shown.
44 changes: 44 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Data/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;

using EasyDataBasicDemo.Models;

namespace EasyDataBasicDemo.Data
{
public class ApplicationDbContext : IdentityDbContext
Expand All @@ -14,5 +16,47 @@ public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)

public DbSet<IdentityUser> ApplicationUser { get; set; }
public DbSet<IdentityRole> ApplicationRole { get; set; }

#region NWind
public DbSet<Category> Categories { get; set; }

public DbSet<Language> Languages { get; set; }

public DbSet<Employee> Employees { get; set; }

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

public DbSet<Product> Products { get; set; }

public DbSet<OrderDetail> OrderDetails { get; set; }

public DbSet<Shipper> Shippers { get; set; }

public DbSet<Supplier> Suppliers { get; set; }

public DbSet<Customer> Customers { get; set; }

public virtual DbSet<CityEntity> Cities { get; set; }


#endregion

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);

modelBuilder.Entity<Category>()
.Property(c => c.CategoryName);

modelBuilder.Entity<OrderDetail>()
.ToTable("Order_Details")
.HasKey(od => new { od.OrderID, od.ProductID });

//to use the following view you will need to run an extra SQL command over the testing DB:
//CREATE VIEW [dbo].[AllCities] AS SELECT Country, City FROM [Customers]
//modelBuilder.Entity<CityEntity>()
// .ToView("AllCities")
// .HasNoKey();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<UserSecretsId>aspnet-EasyDataAspNetCoreTest02-73F88C7B-4F30-4AEA-962D-7D725BB02FB2</UserSecretsId>
<TargetFramework>net8.0</TargetFramework>
<UserSecretsId>EasyData-playground-EasyDataAspNetCoreTest02</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.0" />

<PackageReference Include="Korzh.DbUtils.Import" Version="1.4.1" />
<PackageReference Include="Korzh.DbUtils.SqlServer" Version="1.4.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -20,4 +23,10 @@
<ProjectReference Include="..\..\easydata.net\src\EasyData.EntityFrameworkCore.Relational\EasyData.EntityFrameworkCore.Relational.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="App_Data\EdDemoData.zip">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
31 changes: 31 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Models/NWind/Category.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Threading.Tasks;

using EasyData.EntityFrameworkCore;

namespace EasyDataBasicDemo.Models
{
[MetaEntity(Description = "Categories of Product")]
public class Category
{
//[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("CategoryID")]
public int Id { get; set; }

public int? LanguageId { get; set; }
public Language Language { get; set; }

// [MetaEntityAttr(ShowOnCreate = false, ShowOnEdit = false, ShowOnView = false)]
public string CategoryName { get; set; } = "Category name";

public string Description { get; set; }

[ScaffoldColumn(false)]
public byte[] Picture { get; set; }
}
}
16 changes: 16 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Models/NWind/CityEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using EasyData.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;


namespace EasyDataBasicDemo.Models
{
[Keyless]
[MetaEntity(DisplayName = "City", DisplayNamePlural = "Cities")]
public class CityEntity
{
public string Country { get; set; }

public string City { get; set; }
}
}
35 changes: 35 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Models/NWind/Customer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using EasyData.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace EasyDataBasicDemo.Models
{

[DisplayColumn("Name")]
public class Customer
{
[Column("CustomerID")]
public string Id { get; set; }

[Display(Name = "Company Name")]
public string CompanyName { get; set; }

public string Address { get; set; }

public string City { get; set; }

public string Region { get; set; }

public string PostalCode { get; set; }

public string Country { get; set; }

public string ContactName { get; set; }

public string ContactTitle { get; set; }

public string Phone { get; set; }

public string Fax { get; set; }
}
}
84 changes: 84 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Models/NWind/Employee.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

using EasyData.EntityFrameworkCore;

namespace EasyDataBasicDemo.Models
{
[DisplayColumn("FirstName")]
public class Employee
{
[DatabaseGenerated(DatabaseGeneratedOption.None)]
[Column("EmployeeID")]
public int Id { get; set; }

[Required]
[Display(Name = "Last name")]
public string LastName { get; set; }

[Required]
[Display(Name = "First name")]
public string FirstName { get; set; }

[NotMapped]
public string FullName {
get {
string res = this.FirstName;

if (!string.IsNullOrEmpty(res))
res += " ";

if (!string.IsNullOrEmpty(this.LastName))
res += this.LastName;
return res;
}
}


[MaxLength(30)]
public string Title { get; set; }

public string TitleOfCourtesy { get; set; }

[Display(Name = "Birth date")]
public DateTime? BirthDate { get; set; }

public DateTime? HireDate { get; set; }

public string Address { get; set; }

public string City { get; set; }

public string Region { get; set; }

public string PostalCode { get; set; }

public string Country { get; set; }

[MaxLength(24)]
public string HomePhone { get; set; }

[MaxLength(4)]
public string Extension { get; set; }

[ScaffoldColumn(false)]
public byte[] Photo { get; set; }

public string PhotoPath { get; set; }

public string Notes { get; set; }

[ScaffoldColumn(false)]
public int? ReportsTo { get; set; }

[ForeignKey("ReportsTo")]
public virtual Employee Manager { get; set; }

public virtual ICollection<Order> Orders { get; set; }

}


}
20 changes: 20 additions & 0 deletions playground/EasyDataAspNetCoreTest02/Models/NWind/Language.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using EasyData;
using EasyData.EntityFrameworkCore;

namespace EasyDataBasicDemo.Models
{
public class Language
{
public int Id { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }

public Guid GuidTest { get; set; }
}
}
Loading

0 comments on commit 4393eea

Please sign in to comment.