I have a few tables in SQL Server that I am using to log when a user logs into a Silverlight application.
I have created an entity for each of those tables. One example is ApplicationUsageLog
, where I log the ApplicationID, the Date, and the UserID. Those are mostly pulled from the Silverlight side.
I would like to just create a method called Login(AppID,UserID)
that can do an insert into that table.
Is that possible?
Thanks!
EDIT The following does not work for some reason:
[Invoke]
public void Login(int AppID,string EmployeeNo)
{
var aul = new ApplicationUsageLog{ ApplicationID = AppID, LoginDate = System.DateTime.Now, EmployeeNo = EmployeeNo };
if ((aul.EntityState != System.Data.EntityState.Detached))
{
this.ObjectContext.ObjectStateManager.ChangeObjectState(aul, System.Data.EntityState.Added);
}
else
{
try
{
this.ObjectContext.ApplicationUsageLogs.AddObject(aul);
}
catch (System.Exception e) { }
}
}
I can look at aul
and all looks good. But when I put a breakpoint at the end, this.ObjectContext.ApplicationUsageLogs
is still totally empty....