Still struggling with InitClassEmpty

Posts   
 
    
Jeff M
User
Posts: 250
Joined: 04-Aug-2004
# Posted on: 21-Nov-2005 17:48:19   

Hi Frans.

Using 1.0.2005.1 (November 5, 2005) with VS.Net 2005 beta 2, Adapter and Sql Server 2005 (beta). Uses remoting.

I'm still having a tough time with InitClassEmpty. Here's an example:

Here's the server call:

   public EntityCollection GetManufacturers(string alphaString)
   {
            DataAccessAdapter adapter = new DataAccessAdapter();
            EntityCollection collection = new EntityCollection(new ManufacturerEntityFactory());
            RelationPredicateBucket filter = new RelationPredicateBucket();
            filter.PredicateExpression.Add((ManufacturerFields.ManufacturerName%alphaString));
            ISortExpression sorter = new SortExpression();
            sorter.Add(ManufacturerFields.ManufacturerName | SortOperator.Ascending);
            adapter.FetchEntityCollection(collection, filter, 0, sorter);
            return collection;
    }

The call stack indicates that this method is called in EntityFactories.cs:

public virtual IEntity2 Create()
{
    IEntity2 toReturn = new ManufacturerEntity();   
    // __LLBLGENPRO_USER_CODE_REGION_START CreateNewManufacturer
    // __LLBLGENPRO_USER_CODE_REGION_END
    return toReturn;
}

Which in turn calls this method in ManufacturerEntity.cs:

public ManufacturerEntity():base("ManufacturerEntity")
{
    InitClassEmpty(CreateValidator(), CreateFields()); EntityValidatorToUse = entityValidator;
}

Which leads to this:

protected virtual void InitClassEmpty(IValidator validator, IEntityFields2 fields)
{
    InitClassMembers();
    base.Fields = fields;
    base.IsNew=true;
    base.Validator = validator;         
    // __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
    ManufacturerName = "";
    // __LLBLGENPRO_USER_CODE_REGION_END
}

Which, obviously, leads to a Entity Collection with a bunch of Manufacturer entities with empty ManufacturerName fields.

What am I doing wrong?

Thanks.

Jeff

Jeff M
User
Posts: 250
Joined: 04-Aug-2004
# Posted on: 21-Nov-2005 18:16:23   

Oops... I forgot something from my code, didn't I?

// __LLBLGENPRO_USER_CODE_REGION_START InitClassEmpty
    if (Fields.State == EntityState.New)
    {
        ManufacturerName = "";
    }
// __LLBLGENPRO_USER_CODE_REGION_END

Seems to be solving my problems.

So... I guess I really don't have a problem, do I?

Jeff