You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 22, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 22, 2020. It is now read-only.
Unable to get individual properties from collection document after inheriting from Entity #56
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
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
Whenever I try requesting the documents I added earlier via the enumerator in the MongoRepository, It only returns the Id not until I add a [DataMemebr] attribute on each field/property of the Author class
... 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 myRepo.Where(...)...". The latter is a MongoRepository support question / issue, the former is an issue related to Web API (or other framework).
If you prefer an "opt-in" approach, decorate the class with the DataContract attribute. If this attribute is present, members are ignored unless they have the DataMember. You can also use DataMember to serialize private members.
Activity
RobThree commentedon Dec 7, 2017
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.
huzaynbolt commentedon Dec 7, 2017
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
RobThree commentedon Dec 7, 2017
Yes
Because otherwise you won't be able to add it 😉
huzaynbolt commentedon Dec 7, 2017
But if I am not working with the WCF,Web API ... frameworks would removing it still makes it work the
way it should
RobThree commentedon Dec 7, 2017
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 😉
huzaynbolt commentedon Dec 7, 2017
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
Whenever I try requesting the documents I added earlier via the enumerator in the MongoRepository, It only returns the Id not until I add a [DataMemebr] attribute on each field/property of the Author class
RobThree commentedon Dec 7, 2017
... 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
myRepo.Where(...)...". The latter is a MongoRepository support question / issue, the former is an issue related to Web API (or other framework).But as said; Web API requires the
DataMemberattribute since theEntityclass is annotated with theDataContractattribute:nk-gears commentedon Dec 28, 2017
I resolved this challenge using CustomResolver. Please refer here for more details.
https://refactorthat.wordpress.com/2014/01/18/getting-datacontract-atttribute-and-web-api-to-work-together/