redarrowlabs / Argo

:squirrel: c# object => json.api relational mapping
MIT License
7 stars 3 forks source link

Session Create does not respect instance type #86

Open zeitlerc opened 6 years ago

zeitlerc commented 6 years ago

Session Create relies on the cast type rather than the actual type. For instance, attempting to save a Model class that's cast to an object will cause an exception. Checking the instance type ( entity.GetType() ) would properly save the model in all cases.

var patient = new Patient();
// This explodes because Argo assumes the type is object
await session.Create((object)patient);
engenb commented 6 years ago

ah yes - that should be pretty straightforward to move away from typeof(TModel) to model.GetType()