开发者

Loading A single business object via properties on a related business object

开发者 https://www.devze.com 2023-03-10 05:41 出处:网络
I am tring to Load a single Business object based on properties in its related object. In this case there is an ExtendedMaterial which has a single relationship to Material and to Plant.

I am tring to Load a single Business object based on properties in its related object. In this case there is an ExtendedMaterial which has a single relationship to Material and to Plant.

this method is on an AppServer class. When I run the attached test with this code I get the correct result and a passing test but if I uncomment the line Broker.GetBusinessObject<ExtendedMaterial>("Plant.PlantCode LIKE开发者_JAVA百科 " + plantCode);

then I get the Exception Habanero.Base.Exceptions.InvalidPropertyNameException : The given property name 'PlantCode' does not exist in the collection of properties for the class 'ExtendedMaterial'

What am I doing wrong?

    public ExtendedMaterial GetExtendedMaterial(string materialCode, string plantCode)
    {
      //  return Broker.GetBusinessObject<ExtendedMaterial>("Plant.PlantCode LIKE " + plantCode);
        return Broker.GetBusinessObjectCollection<ExtendedMaterial>("Plant.PlantCode LIKE " + plantCode).FirstOrDefault();

    }


    [Test]
    public void GetExtendedMaterial_WhenExists_ShouldReturnExtendedMaterial()
    {
        //---------------Set up test pack-------------------

        var material = CreateSavedMaterial();
        var plant = GetBOTestFactory<Plant>().CreateSavedBusinessObject();
        var extendedMaterial = CreateSavedExtendedMaterial(plant, material);
        IAppServer appServer = new AppServer(CreateDeviceManagerWithDevice());
        //---------------Assert Precondition----------------
        Assert.AreSame(plant, extendedMaterial.Plant);
        Assert.AreSame(material, extendedMaterial.Material);

        //---------------Execute Test ----------------------
        var actualExtendedMaterial = appServer.GetExtendedMaterial(material.Code, plant.PlantCode);
        //---------------Test Result -----------------------
        Assert.AreSame(extendedMaterial, actualExtendedMaterial);
    }


This does work if your DataAccessor is a DataAccessorDB but I noticed recently in some unit tests that it doesn't work against a DataAccessorInMemory. Try your test using a db and see if that works. If it doesn't please log a bug at http://redmine.habanerowiki.com/

0

精彩评论

暂无评论...
验证码 换一张
取 消