Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Update Not Working
Message
General information
Forum:
ASP.NET
Category:
LINQ
Miscellaneous
Thread ID:
01502033
Message ID:
01502059
Views:
39
>>>Why doesn't this work????
>>>
>>>
>>>using (AppSecurityDataContext dc = GetDataContext())
>>>{
>>>    tblUsersInApplication uia = new tblUsersInApplication
>>>    {
>>>        UserId = um.UserId,
>>>        ApplicationId = LoginCredentials.ApplicationId,
>>>        LastLoginDateTime = DateTime.Now
>>>    };
>>>
>>>    try
>>>    {
>>>        dc.SubmitChanges();
>>>    }
>>>    catch (Exception e)
>>>    {
>>>        Error = e;
>>>    }
>>>}   
>>>
>>>
>>>I get no exceptions. Runs fine. The date/time doesn't show up in the SQL table after it runs.
>>
>>Is this Entity Framework? (I'm guessing it is.)
>>
>>You need to add the new item to the context, if it's not a child entity EF will have created a function something like this:
>>
>>dc.AddTotblUsersInApplication(uia);
>>
>>If it's a child you just add it to the reference collection on the parent entity.
>
>No, it's just a plain old Linq statement. Not EF.
>
>And, I have a bunch of other queries just like this one that work fine.

Whether it's EF or Linq-to-Sql it looks as if John is right. You create an instance of tblUsersInApplication - but how is that given any connection or relationship to the DataContext. The DataContext has no changes to save.
Previous
Reply
Map
View

Click here to load this message in the networking platform