I have imported a CSV file into my Parse app. I would like to be able to access records from the table as a type subclassed from ParseObject. I can get the table, and I can get values from records using e.g. myRecord.Get("MyField"). I would prefer to get fields via properties on my subclass.
FWIW, my client is a Unity desktop app.
To illustrate what I'm after:
[ParseClassName( "MyRecord" )]
public class MyRecord: ParseObject
{
[ParseFieldName( "MyField" )]
public string MyField
{
get { return GetProperty<string>( "MyField" ); }
set { SetProperty<string>( value, "MyField" ); }
}
//....
}
// elsewhere...
void Example()
{
var query = new ParseQuery<MyTable>();
query.FindAsync().ContinueWith( t =>
{
var anObj = t.Result.First(); // anObj is type ParseObject
var a = anObj.Get<string>( "MyField" ); // works fine
// somehow recast anObj to a MyRecord
var b = myRecord.MyField; // How do I get to this?
} );
}
Is this possible?
[edit]
With regard to the idea of casting the anObj: The cast will fail because anObj is not, in fact, of type MyRecord.
My understanding of the root of the problem is that at the time I import the CVS file into Parse, Parse has no notion that the rows can map onto MyRecord, so it creates rows as plain ParseObject instances with the columns built into its dictionary. I think that Parse subclassing is, at its heart, a technique to wrap properties as accessors to the dictionary. I'm hoping (though not really expecting) that Parse provides a native way to do the binding after the fact.
Well. It seems I was making this far more complicated than it actually is. (This is what comes of turning a DB naif loose on a DB. :})
I was under the misimpression that my query was returning a container holding my collection, as opposed to the collection itself. When I query for MyRecord, I get a collection that is actually of type MyRecord, which is what I was after in the first place.
Thanks for the help offered!