Hi, this is my first project using linq for entities. I figured out how to create a new record, I just need to get the identifier that was assigned to it, so I can use it as FK in the extension table when I add records there. I allow users to create a request, the request can be for several pieces of equipment, so I have a Request and RequestedEquipment table. Here is the code I use to create the request:
public void addReq(ReqType reqType, Employee reqBy, Location loc, string comm) { int reqID; Request req = new Request(); req.Comments = comm; req.Employee = reqBy; req.ReqType = reqType; req.RequestStatus = findReqStat(1); req.Location = loc; entities.AddToRequests(req); entities.SaveChanges(); }
How can I get the id of the created request so that I can use it to create the necessary records in the RequestedEquipment table?
source share