This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi; might I say first off what a cool product you've got here. I've been playing around with it a bit more to see if it suits the future direction some of our development is going in and am very impressed. I have, as a result of the testing, come up with one question and one suggestion. Question: I am testing this particularly in a WCF scenario across application domains. I can get retrieving, updating and deleting going however am still struggling a little bit with adding objects. For updating an object across the application domain it involves using the Attach method to get it back into the UnitOfWork context, however when adding a new object there is no equivalent. Whenever I try adding a new object it always mentions that it expects EntityState.New, however EntityState has a non-accessablie set method. Is there a way to force a recently unserialized object into the new state? Suggestion: I've been playing with the model designer a little bit and I quite like it; it works well. I do have a suggestion however again in the context of WCF. For the object to pass correctly across boundaries the object needs to have the DataContractAttribute and DataMemberAttribute's. It would be really cool if there was an option on the entity to say that this object is for WCF so it generates the code automatically like this and perhaps even opens up the Id field as a DataMember too... I look forward to your replies. |
|
|
Hi paymex, [quote user="paymex"]Question: I am testing this particularly in a WCF scenario across application domains. I can get retrieving, updating and deleting going however am still struggling a little bit with adding objects. For updating an object across the application domain it involves using the Attach method to get it back into the UnitOfWork context, however when adding a new object there is no equivalent. Whenever I try adding a new object it always mentions that it expects EntityState.New, however EntityState has a non-accessablie set method. Is there a way to force a recently unserialized object into the new state?[/quote] What state does the entity have? It should have the default state which is New. [quote user="paymex"] Suggestion: I've been playing with the model designer a little bit and I quite like it; it works well. I do have a suggestion however again in the context of WCF. For the object to pass correctly across boundaries the object needs to have the DataContractAttribute and DataMemberAttribute's. It would be really cool if there was an option on the entity to say that this object is for WCF so it generates the code automatically like this and perhaps even opens up the Id field as a DataMember too... [/quote] Good idea. We've added this feature to our backlog. Cheers, Andrew.
|
|
|
Hi Andrew, Thanks for your reply. [quote user="andrew"]What state does the entity have? It should have the default state which is New.[/quote] It gets the entity state of Modified for some reason. From the client side there is no concept of EntityState however after crossing domain boundaries it serializes back to a Modifed state. { public static T PrepareNewObject<T>(T obj) { Type objectType = typeof (T); ConstructorInfo info = objectType.GetConstructor(Type.EmptyTypes); if (info == null) throw new TypeLoadException(objectType.FullName + " is not serializable"); T newObject = (T)info.Invoke(null); foreach (PropertyInfo pi in objectType.GetProperties()) { if (pi.GetCustomAttributes(typeof(DataMemberAttribute), false).Length > 0) pi.SetValue(newObject, pi.GetValue(obj, null), null); } return newObject; } } Cheers, Paul |
|