Say I have a big model with 4 models in it: m1, m2, m3, m4 I use a big model because my view needs all of them but only one model can de declared. Hence I declare the big model in mu view
I want to perform a join query on the data returned by m1 and m2; but I also want to return the result of this join query to my view How can I do this? Can i declare a model whose values will be that of the join query? How do I do that? Thanks
EDIT
Say I have this, (from Yasser's example)
public class MyMainModel {
public Students Student { get; set; }
public Cars Cars { get; set; }
public Houses house {get; set;}
}
public class Students {
public int StudentNo { get; set; }
public string Name { get; set; }
public int Age { get; set; }
}
public class Houses{
public int StudentNo {get; set;}
public string houseName {get; set;}
}
public class Cars {
public int CarNo { get; set; }
public string Name { get; set; }
public string Make { get; set; }
}
I want my main model, MyMainModel to have the car model and a model displaying student names and house names. A model like
public class ModelFromOtherModels{
public int StudentNo {get; set;}
public string HouseName {get; set;}
}
That means I have to perform a Join query on the Student and Houses model. Somthing like
from s in Student
JOIN h in Houses ON h.StudentNo = s.Student No
Select new{
StudentName = s.name,
HouseName = h.houseName
}
So that at the end, MyMainModel will be
public class MyMainModel {
public ModelFromOtherModels newModel { get; set; }
public Cars Cars { get; set; }
}
How can I do this?