Am I missing something.

Posts   
 
    
Anderskj1
User
Posts: 33
Joined: 11-Jan-2005
# Posted on: 18-Jan-2005 09:40:43   

Hi. Bought your product a week ago or so and have been very pleased. But now i´ve come across a very strange problem.

I can´t set a bool value field on a new entity. All others fields works. But when i set the property it just doesnt change, and when i entity.save() i fails because it says i can't insert a NULL value in that colum. the sql thats generated does not contain the colum so its somehow totally omitted.

I have regenerate everything twice. Im on a MS SQL 2000 server and the colum is bit type with length 1.

Any suggestions? This is the code:

GenusreservationEntity genus = new GenusreservationEntity(); genus.Unit = subejaculate.Unit; genus.Quality = subejaculate.Ejaculate.Quality;

genus.Department = new DepartmentEntity(1); genus.Person = subejaculate.Ejaculate.Person; genus.Count = requestedCount; genus.Active = true; // << this stays false in debug genus.SetNewFieldValue("Active", true); // << Doesnt help

genus.Save();

Looking forward to hear from someone soon because we are on a bit of a hurry, (Aint we all)

Thanks in regards

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-Jan-2005 10:48:00   

Did you add code to the GenusreservationValidation class which tests on that field and fails if the value is set to true?

If I do:


[Test]
public void BitTestSet()
{
    ProductEntity product = new ProductEntity();
    product.Discontinued = true;
    Assert.IsTrue(product.Discontinued);
}

It works, so I'm not sure what might cause the problem in your code. The property simply calls SetNewFieldValue() which proceeds if the entity is new OR if the entity is not new and some criteria are met. As your entity is new, it proceeds. it will then call the validator set and if that one returns false, the field is not set and the routine simply returns. The default behavior of a default validator is that it returns true.

Frans Bouma | Lead developer LLBLGen Pro
Anderskj1
User
Posts: 33
Joined: 11-Jan-2005
# Posted on: 18-Jan-2005 11:00:09   

im embarrassed. ....................

public virtual bool Validate(int fieldIndex, object value) { if((int)GenusreservationFieldIndex.Count == fieldIndex) { double count = (double)value;

    if((count % 0.5) == 0 || count >= 0)
        return true;
}

return false;

}

Guess i forgot that i validates on fields. But thanks for spotting my error.!

Thanks and have a nice day Anders

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 18-Jan-2005 11:57:45   

simple_smile

Yes that's the field validator, for tests like 'id > 0'. You should do entity validations in an implementation of IEntityValidator, which you plug into an entity instance at runtime.

Frans Bouma | Lead developer LLBLGen Pro