Backendless Support
 
Solved

MapTableToType issue in C#

Hi,

I have started a project with a client in C# and one in Java. During some parallel programming I've have noticed that Backendless.Data.MapTableToType method doesn't work in C#. In Java the same code works with no problems.

Here is a code example:

Backendless.Data.MapTableToType("Persons", typeof(Person));

List<Person> list = Backendless.Persistence.Of<Person>().Find().Data;

When I run this code I get this exception:

{"Table with the name Person does not exist. Make sure the client class referenced in the API call has the same literal name as the table in Backendless console"}

Is there a way to solve this problem besides changing my classnames to the same name as my tables in backendless?

Leave a Comment

Comments (7)

photo
1

Hi Kris,

Does the Person class belong to a namespace?

Regards,

Mark

photo
1

Yes,

MyCustomProjectNamespace.DataServices.Models

I use the same namespace in my Java project and there it works. Shoud I use com.mbaas.service instead and is the the cause of the problem?

With regards,

Kris

photo
1

Hi Kris,

Can you please try to specify the class name with package in your C# code?

photo
1

I've got one library package with a namespace:

Podisa.PodoAssist.DataServices

In the root I have a DataController who fetches the data. In the subdir Models I have my data classes that I want to map.

Strange thing is when I use business logic I don't have problems with mapping. When I use Backendless.CustomService.Invoke the mapping works perfectly.

photo
1

I was saying about you to try the following code instead:

  1. Backendless.Data.MapTableToType("MyCustomProjectNamespace.DataServices.Models.Persons", typeof(Person));
  2. List<Person> list = Backendless.Persistence.Of<Person>().Find().Data;

Would it work?

photo
1

Sadly it doesn't... still the same error.

"Table with the name Person does not exist. Make sure the client class referenced in the API call has the same literal name as the table in Backendless console"

photo
1

I've currently solved it by using business logic... but I don't think that's the way to go when there is an easier way of fetching data

photo