14 lines
580 B
Plaintext
14 lines
580 B
Plaintext
|
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}));
|
||
|
}
|
||
|
}
|
||
|
}
|