I am looking to use artificial types/properties in my app and am trying to put all the scattered pieces together on how to handle some real world scenarios.
I've been able to do the following:
1. Extend my existing model following the guide in the documentation section "Extend Existing Models with New Types"
2. Create new artificial types and run the schema update against the database
3. Create new instances of the artificial types to insert new entries like so:
IPersistentTypeDescriptor customdataDescriptor = CustomDataContext.Scope.PersistentMetaData.GetPersistentTypeDescriptor("customfieldsNamespace.customfields");
object customdata = customdataDescriptor.CreateInstance(1);
4. Also figured out how to query using dynamic linq like:
var test = CustomDataContext.Scope.ExtentByName("customfieldsNamespace.customfields")
.Where("testcolumn == @0", "test");
Is there a beter way to query artificial types?
Now I'm having trouble with trying update and delete. Are there any examples that show how to do all CRUD operations using artificial types? I'm not sure where to begin. I understand that I can set values using:
PropertyDescriptor productNameDescriptor = productDescriptor.GetProperties()["name"];
productNameDescriptor.SetValue(product, "My Product");
but how can I load an existing record from the database into the PropertyDescriptor instance to be updated?
Also... how can I do a delete operation on an Artificial Type instance?
Any guidance is appreciated.
Thanks,
Mike