开发者

DbReference with custom MongoIdentifier (MongoDB & NoRM)

开发者 https://www.devze.com 2023-01-31 09:25 出处:网络
I\'m a new Mongo user (haven\'t gotten used to the name even... makes me laugh every time), and I have this problem (feeling mongo).

I'm a new Mongo user (haven't gotten used to the name even... makes me laugh every time), and I have this problem (feeling mongo).

I ha开发者_如何转开发ve a class "User", with the MongoIdentifier defined like this:

[MongoIdentifier] 
public string Username { get; set; } 

In another class "Role" I have a DbReference that looks like this:

public DbReference<User> Creator { get; set; } 

This compiles well, but when I try to set the Creator like this:

role.Creator = new Norm.BSON.DbTypes.DbReference<User>(userOnline.Username);

I get the following error:

System.FormatException: Could not find any recognizable digits.

Any ideas why?

Thanks


Found a solution... I had to specify the type of the MongoIdentifier:

public DbReference<User, String> Creator { get; set; } 

and...

role.Creator = new Norm.BSON.DbTypes.DbReference<User, String>(userOnline.Username);
0

精彩评论

暂无评论...
验证码 换一张
取 消