public void TestExecuteResultSetRowByRowWithCustomType() { var parameters = DatabaseObjectCreation.CreateResultSetTestProc(this.connectionType); try { var customType = TypeReference.CreateGeneratedType(new TypeProperty("Name", typeof(string))); var resultSet = new DatabaseModel.ResultSet { CustomType = customType }; resultSet.Fields.Add(new DatabaseModel.ResultSetField("Counter", DatabaseModel.DataType.Int32, string.Empty)); resultSet.Fields.Add(new DatabaseModel.ResultSetField("StringValue", DatabaseModel.DataType.String, "Name")); FunctionResult result = Execute(this.connectionType, DatabaseHelpers.GetDefaultConnectionString(this.connectionType), "Test Proc", parameters, new object[] { 2 }, new DatabaseModel.ResultSets { resultSet }, OutputOption.RowByRow); var executionPathResults = result.ExecutionPathResult.ToList(); Assert.AreEqual(2, executionPathResults.Count()); Assert.AreEqual("Result", executionPathResults[0].Name); Assert.AreEqual(Names.GetValidName(customType.Name), executionPathResults[0].Value.GetType().Name); Assert.AreEqual("one", executionPathResults[0].Value.Name); Assert.AreEqual("two", executionPathResults[1].Value.Name); } finally { DatabaseObjectCreation.RemoveTestProc(this.connectionType); } }
private void Save() { DatabaseModel.ResultSet savedResultSet = new DatabaseModel.ResultSet { CustomType = SelectedCustomType }; foreach (ResultSetFieldModel nextField in ResultSetFields) { if (string.IsNullOrEmpty(nextField.ColumnName)) { continue; } if (IsMappingCustomType) { if ((!string.IsNullOrEmpty(nextField.OutputName)) && (!CustomTypeProperties.Contains(nextField.OutputName))) { if (ShowMessage != null) { ShowMessage(this, new ShowMessageEventArgs(string.Format("Invalid field name: {0}.", nextField.OutputName), "Save result set", MessageBoxButton.OK, MessageBoxImage.Error)); } return; } } else { if (string.IsNullOrEmpty(nextField.OutputName)) { if (ShowMessage != null) { ShowMessage(this, new ShowMessageEventArgs("Please enter an output name for each column.", "Save result set", MessageBoxButton.OK, MessageBoxImage.Error)); } return; } if (!Names.IsNameValid(nextField.OutputName)) { if (ShowMessage != null) { ShowMessage(this, new ShowMessageEventArgs(string.Format("Output name {0} is not valid.", nextField.OutputName), "Save result set", MessageBoxButton.OK, MessageBoxImage.Error)); } return; } } if ((!string.IsNullOrEmpty(nextField.OutputName)) && (savedResultSet.Fields.Any(f => f.OutputName == nextField.OutputName))) { if (ShowMessage != null) { ShowMessage(this, new ShowMessageEventArgs(string.Format("Duplicate output name: {0}.", nextField.OutputName), "Save result set", MessageBoxButton.OK, MessageBoxImage.Error)); } return; } savedResultSet.Fields.Add(nextField.ResultSetField); } SavedResultSet = savedResultSet; DialogResult = true; }
private static ITypeReference BuildResultSetTypeReference(DatabaseModel.ResultSet resultSet) { if (resultSet.CustomType != null) { return(resultSet.CustomType); } TypeBuilder typeBuilder = new TypeBuilder(); foreach (var nextField in resultSet.Fields) { typeBuilder.AddProperty(nextField.OutputName, nextField.DataType.GetSystemType().MapType()); } return(typeBuilder.CreateTypeReference()); }
public static bool DbSucceed(this DatabaseModel.ResultSet result) => result.ReturnValue >= 0;
public static AppCore.Result <IEnumerable <T> > ToListActionResult <T>(this DatabaseModel.ResultSet result, string message = "") where T : class, new() => AppCore.Result <IEnumerable <T> > .Set(success : result.ReturnValue >= 0, code : Math.Abs(result.ReturnValue), data : result.GetModels <T>(), message : message);
public static AppCore.Result <T> ToActionResult <T>(this DatabaseModel.ResultSet result, string message = "") where T : class, new() => AppCore.Result <T> .Set(success : result.ReturnValue >= 0, code : Math.Abs(result.ReturnValue), data : result.GetModels <T>().FirstOrDefault(), message : message);
public static AppCore.Result ToActionResult(this DatabaseModel.ResultSet result, string message = "") => AppCore.Result.Set(success: result.ReturnValue >= 0, code: Math.Abs(result.ReturnValue), message: message);
public ResultSetViewModel(DatabaseModel.ResultSet resultSet) { ResultSetFields = new ObservableCollection <ResultSetFieldModel>(resultSet.Fields.Select(f => new ResultSetFieldModel(this, f))); selectedCustomType = resultSet.CustomType; }