在我的第一個問題中,我沒有解釋清楚。但是現在我需要從實體框架類中選擇一些列。如何在實體框架中選擇多個列?
var Muestra = Cecytec.asignatura.Select(Z => new asignatura { nombre = Z.nombre, horasPorSemana = Z.horasPorSemana, nivel = Z.nivel, unidades = Z.unidades }).ToList();
從我的類(表) 「asignatura」 我有這樣的:
public partial class asignatura
{
public asignatura()
{
this.criterioevaluacion = new HashSet<criterioevaluacion>();
this.evaluacion = new HashSet<evaluacion>();
this.examen = new HashSet<examen>();
this.alumno = new HashSet<alumno>();
this.horario = new HashSet<horario>();
this.profesor = new HashSet<profesor>();
}
public int idAsignatura { get; set; }
public Nullable<int> horasPorSemana { get; set; }
public string nombre { get; set; }
public Nullable<int> nivel { get; set; }
public Nullable<int> unidades { get; set; }
public int semestres_idsemestres { get; set; }
public virtual semestres semestres { get; set; }
public virtual ICollection<criterioevaluacion> criterioevaluacion { get; set; }
public virtual ICollection<evaluacion> evaluacion { get; set; }
public virtual ICollection<examen> examen { get; set; }
public virtual ICollection<alumno> alumno { get; set; }
public virtual ICollection<horario> horario { get; set; }
public virtual ICollection<profesor> profesor { get; set; }
}
而且我想表明: '農佈雷', 'horasPorSemana', 'NIVEL', 'unidades' 和' calificacion」
注:‘calificacion’是在另一個類
public partial class evaluacion
{
public int unidad { get; set; }
public Nullable<double> calificacion { get; set; }
public Nullable<int> inasistencia { get; set; }
public string observaciones { get; set; }
public int asignatura_idAsignatura { get; set; }
public virtual asignatura asignatura { get; set; }
}
OMG!第二作品!謝謝Stackoverflow的Member先生 –