I am fairly new to MVC4
and I am working on a complex model: a model that contains a property of type IList
along with properties of primitive types (strings and ints). The property of type IList
should use a stored procedure and the primitive types uses a regular link query. Here is the code for the model:
public class EditUserModel
{
public IList<UserTranscript> UserTranscripts { get; set; }
public int? PersonID { get; set; }
public string UserName { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string LastName { get; set; }
public string Address { get; set; }
public string City { get; set; }
public string StateCode { get; set; }
public string PostalCode { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
}
Here is the code for the UserTranscript class:
public class UserTranscript
{
public decimal Score { get; set; }
public DateTime CompletionDate { get; set; }
public string Status { get; set; }
}
Here is my method:
public EditUserModel GetUserRecord(int personid)
{
//using (var db = new TceoModel.TceoContext())
//{
MyContext db = new MyContext();
var user = (from p in db.People
from pu in db.PersonUsernames.Where(f => f.PersonID == p.UPID).DefaultIfEmpty()
from pe in db.PersonEmails.Where(a => a.PersonID == p.UPID).DefaultIfEmpty()
from pa in db.Addresses.Where(c => c.PersonID == p.UPID).DefaultIfEmpty()
from lnr in db.Activities.Where(y => y.ActivityID == un.ActivityID).DefaultIfEmpty()
from tr in db.uspTranscripts(personid)
where p.UPID == personid
select new EditUserModel
{
PersonID = p.UPID,
UserName = pu.Username,
Email = pe.Email,
FirstName = p.FirstName,
MiddleName = p.MiddleName,
LastName = p.LastName,
Address = pa.Address1,
City = pa.City,
StateCode = sc.StateAbbr,
PostalCode = pa.Zip,
Phone = pp.PhoneNumber
}).AsEnumerable().Select(s => new UserTranscript() {
**How to return a list of UserTranscripts using the stored procedure db.uspTranscripts(personid)**
});
My question is, how can I return the user list of transcripts on the second query using the db.uspTranscripts(personid)
stored procedure?
Thanks.