parse-community / Parse-SDK-dotNET

Parse SDK for .NET, Xamarin, Unity.
http://parseplatform.org
Apache License 2.0
323 stars 261 forks source link

Values of type Number returned using Subclassing are all 0 #325

Closed NadjibR closed 4 years ago

NadjibR commented 4 years ago

I'm new to github, and it's the first time I report an issue in this platforme.

The problem is that all the fields of type Number return 0 using subclassing. There is no problem with String fields.

Making the same query (without subclassing) works just fine.

Let's say we have a class named Category with 2 columns :

ID (Type = Number) Name (Type = String)

Subclass of ParseObject :

[ParseClassName("Category")]
public class CategoryCollection : ParseObject
{
    [ParseFieldName("ID")]
    public double ID { get; }

    [ParseFieldName("Name")]
    public string Name  {  get ; }
 }

Now register the subclass, initialize ParseClient and make the query :

ParseObject.RegisterSubclass<CategoryCollection>();
....
ParseClient.Initialize(config);
....
IList<CategoryCollection> categoryList = new List<CategoryCollection>();

var query = new ParseQuery<CategoryCollection>();
IEnumerable<CategoryCollection> categories = await query.FindAsync().ConfigureAwait(false);

foreach (CategoryCollection category in categories)
{
    categoryList.Add(category);
}

After checking the categoryList with a breakpoint, I can see the category Name, but all the IDs are equals to 0.

If I make the same query without subclassing ParseObject, the IDs returned are all like in the database.

I hope this was informative, and can help you solve the problem.

Dev Env :

Visual Studio 2019 Communty (With Latests Updates) NETStandard.Library 2.0.3 Xamarin.Forms 4.4.0.991640

Parse-SDK-dotNET 2.0.0-develop

TobiasPott commented 4 years ago

Hi @NadjibR,

so it not quite clear to me where the issue comes from as what you states and what your code says is not explicit. I must assume that you have some data already put inside your parse server. Is that so and if that is the can you check for the values of your object using Parse Dashboard for example?

Can you check whether the results of your query are different when you use another type for your ID field e.g. int or float or long?

At this point I cannot tell if any data you save into your parse server is actually stored there correctly or if something is wrong at that point already.

As you explicitly stated you experience this issue when using "subclassing" may I ask you if you tried it any other way as mentioned in the guide?

NadjibR commented 4 years ago

Sorry, I had to mention that.

I've injected the data of Category Class in Parse Server using Parse Dashboard.

And I've tried all the data types mentionned in the doc for the Number data type (double, long, float). Same result.

I'm coding an Xamarin.Form application. And as I said before, without subclassing the Category class, everything is ok, but If I use subclassing to make the query, all values of ID field returned will be 0.

Let me know if you want more infos.

NadjibR commented 4 years ago

Am I using a dead SDK project or what ?

TobiasPott commented 4 years ago

Did you ever try to save data to your parse using the SDK (by code) (with and without subclassing)?

As far as I can tell, doing so works fine for my side, in a .NET Standard app for Windows or using Parse within an Unity app for Android or iOS, so it might not be that simple to just point on "subclassing" and say it is broken.

It depends on how you may define "dead", you may have noticed that this project is maintained by the community without one or more specific person assigned to manage and fix bugs and errors by default. Thus discussing and solving issues is not a "I demand" situation but more a situation to contribute and help each other to our best knowledge and capabilities.

TobiasPott commented 4 years ago

@NadjibR could you try to change your code to actually match the guide for subclassing and using properties when doing so? I'm referring to the 'Properties and Methods' subsection as you are using custom properties but do not at all stick to the guide (https://docs.parseplatform.org/dotnet/guide/#properties-and-methods).

When changing your class to match the guide using the "GetProperty" and "SetProperty" methods inside the properties getter and setter blocks it works for me, regardless of the numeric type I use for the "ID" property of your class.

NadjibR commented 4 years ago

Mmm yes, that was true. I didn't use the GetProperty with the ID field, I used it with the Name field, and this is why it worked. Sorry.

And sorry also about the " a dead SDK project", I forget that no one is paid to support me.

Thanks bro :)

Another think that I want to ask you about is the local store / caching / pin of parseObject like in java SDK, is this available in .Net ?

https://stackoverflow.com/questions/60211006/parse-server-local-datastore-in-parse-sdk-dotnet

TobiasPott commented 4 years ago

@NadjibR you're welcome =) The guide is somewhat confusing in some aspects and unfortunately partially outdated since @TheFanatr did the .NET Standard rewrite.

Regarding your question about pinning/caching of objects. I wasn't aware this is a thing and I didn't stumble across it until you mentioned it. I will need to take a look in the sources to determine in there is or was anything similar to that and perhaps need to check the Java SDK to what the 'pinInBackground' method does. I cannot tell when I'll be able to do so and I would consider it not supported as of now in the .NET SDK