Can UnionList be marked serializable?

Posts   
 
    
Posts: 98
Joined: 10-Nov-2006
# Posted on: 20-Dec-2018 00:25:42   

In my application, I add PredicateExpressions to the ASP.NET session state. ASP.NET implements this by using binary serialization on the PredicateExpression.

Up though LLBLGen 5.4, this worked fine. However, after updating to version 5.5, it's failing with an exception like this:


System.Web.HttpException (0x80004005): Couldn't update session state for SessionID: au41gjeocfqsoibc0mtx0q5n ---> System.Web.HttpException (0x80004005): Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. ---> System.Runtime.Serialization.SerializationException: Type 'SD.LLBLGen.Pro.ORMSupportClasses.UnionList`1[[SD.LLBLGen.Pro.ORMSupportClasses.DerivedTableDefinition, SD.LLBLGen.Pro.ORMSupportClasses, Version=5.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27]]' in Assembly 'SD.LLBLGen.Pro.ORMSupportClasses, Version=5.5.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27' is not marked as serializable.

From the names of the classes involved (UnionList<T>), I assume that this is a result of adding support for SQL Unions in 5.5.

I grabbed the latest LLBLGen source code, added [Serializable] to UnionList<T> and UnionListElement<T>, and linked that build to my application, and my application now works correctly.

Not every predicate seems to include a UnionList. In my case, the predicates that did include it were ones like this:


var saleTotalQ =
    Functions.Coalesce(
        qf.Create()
        .Select(SaleElementFields.Total)
        .Where(SaleElementFields.SupporterId.Equal(SupporterWithRolesFields.SupporterId)
                .And(SaleElementFields.ProjectId.Equal(ProjectId.Value))
            )
            .Sum(),
        0);

var paymentTotalQ = Functions.Coalesce(
    qf.Create()
        .Select(PaymentFields.Amount)
        .Where(
            PaymentFields.SupporterId.Equal(SupporterWithRolesFields.SupporterId)
            .And(PaymentFields.ProjectId.Equal(SupporterWithRolesFields.ProjectId))
        )
        .Sum(),
    0);

var predicatetoSerialize = saleTotalQ.GreaterThan(paymentTotalQ);


Would you be willing to add [Serializable] to UnionList<T> and UnionListElement<T> to enable my application to continue to work?

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 20-Dec-2018 08:17:45   

Sure, will add them in the next build of the hotfix builds of 5.5.1.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 98
Joined: 10-Nov-2006
# Posted on: 20-Dec-2018 18:28:06   

Great! Thanks for the quick response.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39590
Joined: 17-Aug-2003
# Posted on: 28-Dec-2018 15:14:53   

Please get the latest 5.5.1 hotfix build (from the site or nuget) to get the attributes on the classes specified. If there are other classes you need these attributes on, let me know simple_smile

Frans Bouma | Lead developer LLBLGen Pro