2
I am using the mysql database. I have 2 tables one of questions and options related to the question. For every access I make to the system I need to take the questions randomly and obviously the related options. I found in google a way to take the questions randomly because mysql does not have the Guid as in Sql server. Below the code:
var teste = (from q in db.Questoes orderby rnd.Next() select q).Take(2)
Now how do I Join this query with my options table? Join is done with the field Questoes.Id
and Opcoes.QuestoesId
public class QuestaoModel
{
public int Id { get; set; }
[Column(TypeName = "varchar(MAX)")]
public string Pergunta { get; set; }
public int TemaId { get; set; }
public virtual TemaModel Tema { get; set; }
public virtual ICollection<OpcaoModel> Opcoes { get; set; }
public virtual RespostaModel Resposta { get; set; }
}
public class OpcaoModel
{
public int Id { get; set; }
public string opcaoResposta { get; set; }
public int QuestaoId { get; set; }
public virtual QuestaoModel Questao { get; set; }
}
Can someone give me a hand?
It’s not just giving one
include
of the relationship??– novic