有关如何使用.net对象表示以下内容的任何想法?
{
_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’ ] }
}
}
答案 0 :(得分:1)
我想它可能看起来像
[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
}
我相信Mongo和WCF都支持词典,所以是的,你可以将追随者改为字典