Reputation: 227
Any ideas on how to represent the following with .net objects?
{
_id: ’T4Y...AC’, // base64-encoded ObjectId
name: ’Rick’,
profile: { ... age, location, interests, etc. ... },
followers: {
"T4Y...AD": { name: ’Jared’, circles: [ ’python’, ’authors’] },
"T4Y...AF": { name: ’Bernie’, circles: [ ’python’ ] },
"T4Y...AI": { name: ’Meghan’, circles: [ ’python’, ’speakers’ ] }
}
}
Upvotes: 3
Views: 4394
Reputation: 3084
I would imagine it might look something like
[DataContract]
public class data
{
[BsonId]
[DataMember(Order = 0]
public BsonObjectId { get; set; }
[DataMember(Order = 1]
public string name { get; set; }
[DataMember(Order = 2]
public Profile profile { get; set; }
[DataMember(Order = 3]
public Dictionary<string,Follower> followers { get; set;}
}
[DataContract]
public class Profile
{
[DataMember(Order = 0]
public int age { get; set; }
[DataMember(Order = 1]
public string location { get ;set; }
[DataMember(Order = 2]
public string interests { get ;set; }
}
[DataContract]
public class Follower
{
[DataMember(Order = 0]
public string name { get; set; }
[DataMember(Order = 1]
public string[] circles
}
I believe both Mongo and WCF support dictionaries so yes you could change Followers to a dictionary
Upvotes: 1