silent update failure

Posts   
 
    
Philip
User
Posts: 17
Joined: 01-May-2009
# Posted on: 11-Feb-2010 23:01:32   

Hi there,

I can't find anything similar to this in the forum, so I'll ask. I am trying to do a simple update to the object after inserting it. Below is the test that fails.

I'm using LLBLGen 1.6 Final, SelfServicing, with LinqADODS template in C# .Net 3.5

I have a table:

create table session (
session_id int identity(1,1) not null,
username varchar(20) not null,
guid varchar(100) null,
ts_session_started datetime not null default getdate(),
ts_session_extended datetime null,
ts_session_expired datetime null,
ts_session_ended datetime null,
)

I generated the code and do the following in my test.

[Test]
public void SessionUpdate()
{
    var datasource = new LinqMetaData();
    var session = new SessionEntity
                      {
                          Username = "Test Validate",
                          Guid = Guid.NewGuid().ToString(),
                          TsSessionStarted = DateTime.Now,
                          TsSessionExtended = DateTime.Now
                      };
    session.Save();

    session.Username = "new name";
    session.Save();
    var returnedSession = datasource.Session.Single(s => s.Guid == session.Guid);
    Assert.AreEqual("new Name", returnedSession.Username);
}

All of my other entities update when saved as expected. What can cause this? The SQL Profiler shows that the update query isn't even sent, however, when inspecting the entity before and after .Save(), I can see that IsDirty is true before and false after. Just no update query happening.

I'd appreciate any ideas. This seems like such a fundamental failure, I'm afraid the answer is obvious and I'm doing something totally dumb.

Thanks!

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 12-Feb-2010 10:51:16   

I'm using LLBLGen 1.6 Final

I guess you mean v.2.6 Can you tell us which runtime library build are you using?

Now, the same happens if you filter by sessionId rather than the guid, right?

Philip
User
Posts: 17
Joined: 01-May-2009
# Posted on: 12-Feb-2010 15:27:57   

Yes, sorry, I meant 2.6 final. It was released on "October 9th, 2009". I think that's the build.

As for your other question about filtering on SessionId, yes, I tried that as well. Same result.

I have found a new clue. Although SessionId is a primary key in the db, I can't construct the entity like this:

var e = new SessionEntity(123)

It says there's no constructor that takes an int. I have regenerated it few times. I see the file is actually regenerated, but still no constructor that takes an int.

Thanks, Philip

Philip
User
Posts: 17
Joined: 01-May-2009
# Posted on: 12-Feb-2010 15:44:41   

OK, I found my problem. The constructor issue was the clue I needed. It seems that I wasn't creating a primary key in the db after all. disappointed I had the alter table command in my script, but I had a mistake in there. Ahh well.

Thanks anyway!