Add template working
This commit is contained in:
parent
693bbc0c0d
commit
b4362789cc
|
@ -9,7 +9,6 @@
|
|||
<DocumentationFile>bin\$(Configuration)\$(AssemblyName).xml</DocumentationFile>
|
||||
<PublishDependencyDocumentationFiles>true</PublishDependencyDocumentationFiles>
|
||||
<AnalysisLevel>preview</AnalysisLevel>
|
||||
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -18,13 +17,16 @@
|
|||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="6.0.2" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<AdditionalFiles Include=".\Extensions\AddToEntityTemplate.csx" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\BlueWest.Data.Capital\BlueWest.Data.Capital.csproj" />
|
||||
<ProjectReference Include="..\BlueWest\BlueWest.csproj" />
|
||||
<ProjectReference Include="..\include\BlueWest.MapTo\src\BlueWest.MapTo\BlueWest.MapTo.csproj" OutputItemType="Analyzer" ReferenceOutputAssembly="false" />
|
||||
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="..\include\BlueWest.MapTo\src\BlueWest.MapTo\MapTo.props" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -15,10 +15,10 @@ namespace BlueWest.WebApi.EF
|
|||
/// Companies.
|
||||
/// </summary>
|
||||
[EfAddMethods(typeof(CompanyCreate), typeof(CompanyUnique))]
|
||||
[EFUpdateMethods(typeof(int),
|
||||
/*[EFUpdateMethods(typeof(int),
|
||||
"Id",
|
||||
typeof(CompanyUpdate),
|
||||
typeof(CompanyUnique))]
|
||||
typeof(CompanyUnique))]*/
|
||||
|
||||
public DbSet<Company> Companies { get; set; }
|
||||
|
||||
|
@ -26,10 +26,10 @@ namespace BlueWest.WebApi.EF
|
|||
/// Industries.
|
||||
/// </summary>
|
||||
[EfAddMethods(typeof(IndustryCreate), typeof(IndustryUnique))]
|
||||
[EFUpdateMethods(typeof(int),
|
||||
/*[EFUpdateMethods(typeof(int),
|
||||
"Id",
|
||||
typeof(IndustryUpdate),
|
||||
typeof(IndustryUnique))]
|
||||
typeof(IndustryUnique))]*/
|
||||
|
||||
public DbSet<Industry> Industries { get; set; }
|
||||
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace BlueWest.WebApi
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class EFUpdateMethodsAttribute : Attribute
|
||||
{
|
||||
public EFUpdateMethodsAttribute( Type keyType = null, string keyName = "Id", Type updateDto = null, Type returnType = null) { }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace BlueWest.WebApi
|
||||
{
|
||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
|
||||
public class EfAddToListMethodAttribute : Attribute
|
||||
{
|
||||
public EfAddToListMethodAttribute( Type keyType = null, string keyName = "Id", Type updateDto = null, Type returnType = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace {Namespace}
|
||||
{
|
||||
public static partial class {entityTypeName}Extensions {
|
||||
public static (bool, {readTypeFullName}) Add{entityTypeName}(
|
||||
this {contextFullName} dbContext, {createTypeFullName} {toCreateVarName}) {
|
||||
var {newEntityVarName} = new {entityTypeFullName}({toCreateVarName});
|
||||
dbContext.{propertyName}.Add({newEntityVarName});
|
||||
var success = dbContext.SaveChanges() >= 0;
|
||||
return (success, new {readTypeFullName}({newEntityVarName}));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
Subproject commit acb9bdabd148dd2184866b9fd6da4dcc772fe464
|
||||
Subproject commit 5006902892221cef14127637b20f6f59ae28a311
|
Loading…
Reference in New Issue