Bharani Dharan
2015-03-26 01:07:49 UTC
I uses the below to code to ignore some property inside a class using
BsonIgnore. But it is ignoring the total object.
public class User { public string Username { get; set; } public string Password { get; set; } [BsonIgnore,JsonProperty(PropertyName = "CreateDate")] public ICollection<Role> Roles { get; set; } } public class Role { public int RoleId {get; set;} public string RoleName { get; set; } public DateTime CreateDate { get; set;} }
I have 2 question.
1. How to ignore only certain properties inside a class? I should not use BsonIgnore directly inside Role class.
2. How to ignore multiple properties? Something like below.
Code:
[BsonIgnore,JsonProperty(PropertyName = "CreateDate")] [BsonIgnore,JsonProperty(PropertyName = "RoleId")] public ICollection<Role> Roles { get; set; }
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e4afc79b-d716-47b7-9a37-ef4b4fbe2561%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
BsonIgnore. But it is ignoring the total object.
public class User { public string Username { get; set; } public string Password { get; set; } [BsonIgnore,JsonProperty(PropertyName = "CreateDate")] public ICollection<Role> Roles { get; set; } } public class Role { public int RoleId {get; set;} public string RoleName { get; set; } public DateTime CreateDate { get; set;} }
I have 2 question.
1. How to ignore only certain properties inside a class? I should not use BsonIgnore directly inside Role class.
2. How to ignore multiple properties? Something like below.
Code:
[BsonIgnore,JsonProperty(PropertyName = "CreateDate")] [BsonIgnore,JsonProperty(PropertyName = "RoleId")] public ICollection<Role> Roles { get; set; }
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+***@googlegroups.com.
To post to this group, send email to mongodb-***@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e4afc79b-d716-47b7-9a37-ef4b4fbe2561%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.