'cannot bind data to class and retrieve it from anther form
I have been stuck at this bump for 3 days now, here is the issue:
I have a class named Models, I need to bind specific information to it, when the user logs in it retrieves all the information and then uses it across the application which I haven't been successful in accomplishing, or if there is a way to directly retrieve embeded documents value from mongodb for example:
{
"_id": {
"$oid": "61f05d962e19875728f53884"
},
"username": "YRbicLcyVwY=",
"email": "mR+0ULwyFaY=",
"pin": "sonPU0DOWEA=",
"age": "/4A+0B/jLko=",
"creation date": "zbS8yBCepb4rTRsPSuN+1K9VryjXyZYR",
"admin": "BjBSqbmjcwg=",
"password": "dqAWwktjoFc=",
"theme": "po8uCcnsvoo=",
"timer": "dRvJzHdD/vQ=",
"Questions": {
"Question 1": {
"Question": "Q",
"Answer 1": "Q",
"Answer 2": "Q",
"Answer 3": "Q",
"Answer 4": "Q",
"Correct Answer": "Q"
},
"Question 2": {
"Question": "Q",
"Answer 1": "Q",
"Answer 2": "Q",
"Answer 3": "Q",
"Answer 4": "Q",
"Correct Answer": "Q"
}
}
}
I wanna access Question 1 Question & Answers so I can use it in the application, so upon logging in this is what happenes
public Models Modd;
Modd = BsonSerializer.Deserialize<Models>(result);
My models class
public class Models
{
[JsonProperty("_id")]
public ObjectId Id { get; set; }
[BsonElement("username")]
public string Username { get; set; }
[BsonElement("email")]
public string Email { get; set; }
[BsonElement("pin")]
public string Pin { get; set; }
[BsonElement("age")]
public string Age { get; set; }
[BsonElement("creation date")]
public string CreationDate { get; set; }
[BsonElement("admin")]
public string Admin { get; set; }
[BsonElement("password")]
public string Password { get; set; }
[BsonElement("theme")]
public string Theme { get; set; }
[BsonElement("timer")]
public string Timer { get; set; }
[BsonElement("fake account")]
public string Fakeacc { get; set; }
[BsonElement("questions")]
public Questions Questions { get; set; }
}
public class Questions
{
[BsonElement("Question 1")]
public Question1 Question1 { get; set; }
[BsonElement("Question 2")]
public Question2 Question2 { get; set; }
[BsonElement("Question 3")]
public Question3 Question3 { get; set; }
[BsonElement("Question 4")]
public Question4 Question4 { get; set; }
[BsonElement("Question 5")]
public Question5 Question5 { get; set; }
[BsonElement("Question 6")]
public Question6 Question6 { get; set; }
[BsonElement("Question 7")]
public Question7 Question7 { get; set; }
[BsonElement("Question 8")]
public Question8 Question8 { get; set; }
[BsonElement("Question 9")]
public Question9 Question9 { get; set; }
[BsonElement("Question 10")]
public Question10 Question10 { get; set; }
}
public class Question1
{
[BsonElement("Question")]
public string Question { get; set; }
[BsonElement("Answer 1")]
public string Answer1 { get; set; }
[BsonElement("Answer 2")]
public string Answer2 { get; set; }
[BsonElement("Answer 3")]
public string Answer3 { get; set; }
[BsonElement("Answer 4")]
public string Answer4 { get; set; }
[BsonElement("Correct Answer")]
public string CorrectAnswer { get; set; }
}
any help would be highly appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
