-
Notifications
You must be signed in to change notification settings - Fork 140
Unable to get individual properties from collection document after inheriting from Entity #56
Comments
The DataMember attribute is used by, amongst others, ASP.Net, WCF and OWIN. I assume your project uses either or similar? I can't answer your question since this is not related to MongoRepository but to some other part of your project like aforementioned ASP.Net/WCF/OWIN or such. But, generally, yes, you should add a DataMember attribute to all properties you want serialized. |
No, I am actually using a WEB API does that relate to such framework you enlisted and might it be the cause. You also added the [DataMember] attribute to the Entity class on Id property, Why was that done |
Yes
Because otherwise you won't be able to add it 😉 |
But if I am not working with the WCF,Web API ... frameworks would removing it still makes it work the |
Then it won't do anything.
Why would you want to remove it? It doesn't hurt leaving it in there if that's what you mean? Maybe you can explain a little of your actual problem; remember that as an outsider I have no clue on what you're doing and your initial issue report doesn't clarify much. I'm not psychic 😉 |
Thanks Rob, I am actually using the Repository as my DAL (as it should be), Then I created Proxy classes that inherited from the base Entity class (as stated in your example). Like the Author Class I use as an example above, whenever I try Adding an instance of the object into the repository it work as it should and all filed value are mapped to the mongo documents. The ISSUE |
... via Web API. That's pretty relevant information I think 😉 The quoted could also be read as: "Whenever I try requesting the documents ... from MongoDB using But as said; Web API requires the
|
I resolved this challenge using CustomResolver. Please refer here for more details. |
The sample class I add earlier was
and the response on getting list of authors was
After adding DataMember to each property like below
I was able to get the name and dob as part of the response
Must I add the attribute [DataMember] to every field of my POCO classes before it could map to a field in the container document?
The text was updated successfully, but these errors were encountered: