I am wanting to save a record in a database using a simple LINQ statement. I am finding it is not possible to use a Convert.ToInt32
inside the linq statement like below:
using (var context = new Stc.LeadTracker.DataModel.Models.DBNameContext())
{
var newLead = new DataModel.Models.LeadRequest();
newLead.FormId = Convert.ToInt32(formId);
newLead.Request = queryString;
newLead.Success = true;
newLead.RetryCount = 0;
newLead.CreatedBy = nvCollection["iw"];
newLead.CreatedDateTime = DateTime.Now;
context.LeadRequests.Add(newLead);
context.SaveChanges();
leadId = newLead.LeadRequestId;
}
I can certainly do the conversion before the LINQ statement, was curious to know if that is my only option.