private void WriteDeleteUnique() { var methodParameters = CodeWriterUtils.GetDeleteMethodParameters(table, codeWriterSettings, false, true); if (methodParameters == null || !methodParameters.Any()) { return; } classBuilder.AppendLine($"{CodeWriterUtils.GetDeleteMethodSignature(table, codeWriterSettings, methodParameters)};"); }
private void WriteDeleteCommon(IEnumerable <Parameter> methodParameters, bool isLogicalDelete) { var partialMethodName = CodeWriterUtils.ConvertParametersToMethodNameByPart(methodParameters, codeWriterSettings); WriteDeleteMethodSummary(methodParameters); var methodSignature = CodeWriterUtils.GetDeleteMethodSignature(table, codeWriterSettings, methodParameters); using (classBuilder.BeginNest($"public {methodSignature}")) { CodeWriterUtils.WriteEntryLogging(classBuilder, methodSignature); if (isLogicalDelete) { classBuilder.AppendLine($"var deletedEntity = {CodeWriterUtils.BaseMethodNameDelete}LogicalBy{partialMethodName}({PrintParametersForCall(methodParameters)});"); classBuilder.BeginNest($"if (deletedEntity == null)"); classBuilder.AppendLine($"throw new EntityNotFoundException();"); classBuilder.EndNest(); classBuilder.AppendLine(""); classBuilder.AppendLine("return deletedEntity;"); } else { classBuilder.AppendLine($"int countRowsAffected = {CodeWriterUtils.BaseMethodNameDelete}PhysicalBy{partialMethodName}({PrintParametersForCall(methodParameters)});"); classBuilder.BeginNest("if (countRowsAffected == 0)"); classBuilder.AppendLine("throw new EntityNotFoundException();"); classBuilder.EndNest(); classBuilder.AppendLine(""); classBuilder.BeginNest("if (countRowsAffected != 1)"); classBuilder.AppendLine("throw new Exception(\"Delete affected more than one row.\");"); classBuilder.EndNest(); classBuilder.AppendLine(""); classBuilder.AppendLine("return null;"); } CodeWriterUtils.WriteExitLogging(classBuilder, methodSignature); } }
private void WriteDelete() { var methodParameters = CodeWriterUtils.GetDeleteMethodParameters(table, codeWriterSettings, false, false); classBuilder.AppendLine($"{CodeWriterUtils.GetDeleteMethodSignature(table, codeWriterSettings, methodParameters)};"); }