- Cami Lawson
- SnapObjects
- Thursday, 11 July 2019 01:42 PM UTC
I was working with the Create Web API tutorial and tried to add another call for another table other than Departments. I created a Controller for Persons and all subsequent items, which would take the RetrieveOne for an int on the AdventureWorks2017 sql db for table Person.Person and use the BusinessEntityID similar to the DepartmentID. Noticed that Department is a small int in the db and BusinessEntityID is just an int. Shouldn't make much difference. I'm getting the following errors and cannot for the of me understand what is wrong. Just coming back to PB after being gone to the world of CF/SQL for 20yrs. I have also included an image of my solution just in case that helps.
Error:
InvalidOperationException: Data type of mapped property on model is not compatiable, property: BusinessEntityID
-
SnapObjects.Data.DataModelBinding.BindModel(IList columnSchema, IPocoModelMeta modelMeta, ITypeMapper mapper)
-
SnapObjects.Data.DataModelBinder..ctor(IModelFactory factory, IList columnSchema, ITypeMapper typeMapper)
-
SnapObjects.Data.DataModelBinderFactory.GetBinder(IList columnSchema, ITypeMapper typeMapper, Type modelType)
-
SnapObjects.Data.AdoDbResultSet..ctor(IAdoDbDataVisitor dataVisitor, ITypeMapper typeMapper, Type modelType)
-
PowerBuilder.Data.AdoDbDataSource.Retrieve(object[] arguments)
-
PowerBuilder.Data.DataStore.Retrieve(object[] arguments)
-
WebAPI1.Services.PersonService.RetrieveOne(int id) in
-PersonService.cs
- }
- public IDataStore RetrieveOne(int id)
- {
- var dataStore1 = new DataStore("d_person", _dataContext);
- dataStore1.Retrieve(id);
- return dataStore1;
- }
- public int Create(D_Person person)
- {
-
WebAPI1.Controllers.PersonsController.RetrieveOne(int id) in
-PersonsController.cs
- [HttpGet("{id}")]
- [ProducesResponseType(typeof(D_Person), StatusCodes.Status200OK)]
- [ProducesResponseType(StatusCodes.Status404NotFound)]
- public ActionResult RetrieveOne(int id)
- {
- var person = _personservice.RetrieveOne(id);
- if (person.RowCount == 0)
- {
- return NotFound();
- }
-
lambda_method(Closure , object , object[] )
-
Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(object target, object[] parameters)
-
Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor+SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, object controller, object[] arguments)
-
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
-
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
-
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
-
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
-
Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
-
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
-
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
-
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(ref State next, ref Scope scope, ref object state, ref bool isCompleted)
-
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
-
Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
-
Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
-
Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
-
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.