private void WriteGetByCustomer() { var methodParameters = CodeWriterUtils.GetGetMethodParameters(table, codeWriterSettings, true, false); if (methodParameters == null || !methodParameters.Any()) { return; } classBuilder.AppendLine($"{CodeWriterUtils.GetGetMethodSignature(table, codeWriterSettings, methodParameters)};"); }
private void WriteGetCommon(IEnumerable <Parameter> methodParameters, string innerJoinClause, string columnsToReturn) { WriteGetMethodSummary(methodParameters); var methodSignature = CodeWriterUtils.GetGetMethodSignature(table, codeWriterSettings, methodParameters); using (classBuilder.BeginNest($"public {methodSignature}")) { CodeWriterUtils.WriteEntryLogging(classBuilder, methodSignature); var sqlCommandText = ConstructSqlQuery(methodParameters, innerJoinClause, columnsToReturn); var entityVariableName = "entity"; classBuilder.AppendLine($"{table.NetName} {entityVariableName} = null;"); WriteBeginCreateConnection(); WriteBeginCreateCommand(); classBuilder.AppendLine($"command.CommandText = {sqlCommandText};"); WriteAddParametersToCommand(methodParameters); WriteBeginExecuteReader(); WriteBeginReadReaderSingle(); // TODO: KE - discuss the following commented block -- I think this is a good idea for us until our schema is made to match business rules /*using (cb.BeginNest("if (reader.Read())")) * { * cb.AppendLine("throw new InvalidOperationException(\"Multiple rows match the specified criteria.\");"); * } * * cb.AppendLine("");*/ classBuilder.AppendLine($"{entityVariableName} = ({table.NetName}){_serviceProviderFieldName}.GetService(typeof({table.NetName}));"); WriteParseEntityFromReader(entityVariableName); // TODO: KE - parse the org unit information coming back and populate the entity's org unit so that WithCustomerAssetOrganization does not have to be called at the service layer, also need to modify returned columns classBuilder.EndNest(); classBuilder.EndNest(); classBuilder.EndNest(); classBuilder.EndNest(); WriteReturnEntityIfNotNull(entityVariableName); CodeWriterUtils.WriteExitLogging(classBuilder, methodSignature); } classBuilder.AppendLine(""); }
private void WriteGet() { var methodParameters = CodeWriterUtils.GetGetMethodParameters(table, codeWriterSettings, false, false); classBuilder.AppendLine($"{CodeWriterUtils.GetGetMethodSignature(table, codeWriterSettings, methodParameters)};"); }