CodeLiturgy.Dashboard/BlueWest.Api/Context/Templates/AddToEntityTemplate.csx

9 lines
394 B
Plaintext
Raw Normal View History

2022-08-28 20:00:09 +03:00
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}));
}