Inheriting an Entity with no related table/persistence in database

Posts   
 
    
Posts: 36
Joined: 02-May-2012
# Posted on: 01-Feb-2013 19:56:17   

I have searched through the forums here and haven't found exactly what we are trying to do although I found a thread from 2009 that said it's not possible in designer to have an entity/sub-type where there is no database table.

Using adapter, we want to add one field to an entity that is temporary, and used for calculations in the middleware but only in one part of the app, and the lead designer doesn't want to add the property to the main entity, since most of the time it is not necessary (overhead?, confusion), so he wanted to create a subclass/inherit a new class from an entity, add the field and pass that from client to middleware via remoting iis.

However, this doesn't work when remoting. Is there any way to do it or do we have to either fake a table for the designer to generate or just add the property to the actual entity?

namespace STaCS.CW.Middleware.EntityClasses { [Serializable] public class SampleVolumeChange : SampleEntity { private decimal? _sourceSampleVolumeVal = null;

    [Browsable(true)]
    public decimal? SourceSampleVolumeVal { get { return _sourceSampleVolumeVal; } set { _sourceSampleVolumeVal = value; } }

    protected override void SerializeOwnedData(SerializationWriter writer, object context)
    {
        base.SerializeOwnedData(writer, context);
        writer.WriteNullable(_sourceSampleVolumeVal);
    }

    protected override void DeserializeOwnedData(SerializationReader reader, object context)
    {
        base.DeserializeOwnedData(reader, context);
        _sourceSampleVolumeVal = reader.ReadNullableDecimal();
    }
}

thoughts/ideas/not possible?

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Feb-2013 06:35:44   

You can't add a field that doesn't have a mapping target (it isn't on DB). What you can do is add a custom in-memory property, like you are doing right now.

Why exactly isn't working on remoting? Are you using Normal or Fast serialization? (ref...).

David Elizondo | LLBLGen Support Team
Posts: 36
Joined: 02-May-2012
# Posted on: 04-Feb-2013 14:19:09   

daelmo wrote:

You can't add a field that doesn't have a mapping target (it isn't on DB). What you can do is add a custom in-memory property, like you are doing right now.

Why exactly isn't working on remoting? Are you using Normal or Fast serialization? (ref...).

We are using Fast. And with remoting turned off, it worked fine. When turned on, there was a cast exception: can't cast between the two types. We figured it was a serialization issue and tried a few things there, but kept getting that cast exception as well as not being able to step across from client side code to middleware code through the method that passed the new inherited class, which is very strange behaviour.

In the end, we created a new class that contained the "parent" entity as a property and the decimal field as a property and passing that across seems to work, although we are still testing that right now.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 05-Feb-2013 06:02:24   

KerryKilgour wrote:

In the end, we created a new class that contained the "parent" entity as a property and the decimal field as a property and passing that across seems to work, although we are still testing that right now.

I think the key was to add that as a property, as there is no field to support it. Let us know what you figure out in your tests. If you need further help please post the exact cast exception message and stack trace and a background on how to reproduce it over here.

David Elizondo | LLBLGen Support Team