views:

15

answers:

0

Hi everybody, I have a problem with LINQ to Entities. When I try to save data I obtain an error: Error error during the updating of items. for further information see InnerException.

The stack is:

An unexpected exception type was thrown  
Expected: System.ArgumentException  
 but was: TAP2009.AuctionSite.Interfaces.UnavailableDbException : [Login]      DBEntities.SaveChanges():   in   System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager    stateManager, IEntityAdapter adapter)  
   in System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)    
   in System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave)  
   in System.Data.Objects.ObjectContext.SaveChanges()

the code is:

Session s = new Session()
{
    id = 1, 
    username = username, 
    site = Name, 
    creation_date = new DateTime()
};

DBEntities.AddToSession(s);  
System.Diagnostics.Debug.Print("count: " +   q2.Count().ToString());  
DBEntities.SaveChanges();  
DBEntities.Refresh(RefreshMode.StoreWins, s);

return s;

the designer.cs is:

public static Session CreateSession(int id, string username, 
    string site, global::System.DateTime creation_date)    
{  
    Session session = new Session();  
    session.id = id;  
    session.username = username;  
    session.site = site;  
    session.creation_date = creation_date;  

    return session;  
}

Where I wrong?
Thanks Fabio