I'm intrigued by:
catch (Exception e)
{
Error = e;
}
?
>I don't know what the hell I was thinking. What I wanted was:
>
>
>using (AppSecurityDataContext dc = GetDataContext())
>{
> tblUsersInApplication uiaRow = (from uia in dc.tblUsersInApplications
> where uia.UserId == um.UserId &&
> uia.ApplicationId == LoginCredentials.ApplicationId
> select uia).FirstOrDefault();
>
> uiaRow.LastLoginDateTime = DateTime.Now;
>
> try
> {
> dc.SubmitChanges();
> }
> catch (Exception e)
> {
> Error = e;
> }
>}
>
>
>Now it works. I gotta quit drinkinig when I'm coding...
>
>
>
>>>>>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.
>>
>>"By plain old Linq" do you mean Linq to Sql?
>>
>>If that's the case, Michael Collins gave you the correct syntax:
>>
dc.tblUsersInApplications.InsertOnSubmit(uia);
>>
>>or if you have a child relation by adding it to the child collection on the parent object.
>>
>>The DC has to know about the object in order for it to be persisted back to the store.