value of type 'boolean' cannot be converted to 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate'

Posts   
 
    
etilaf
User
Posts: 2
Joined: 10-Dec-2014
# Posted on: 10-Dec-2014 16:21:04   

I,

when i use the isNull in querySpec i got "value of type 'boolean' cannot be converted to 'SD.LLBLGen.Pro.ORMSupportClasses.IPredicate'" because is using the isNull from the 'SD.LLBLGen.Pro.ORMSupportClasses.EntityFieldCore' instead of the extension from the 'SD.LLBLGen.Pro.QuerySpec.IsNullPredicateProducers' class.

This is my code :

 Public Function getData() As EntityCollection(Of DefGroupepaieEntity)
             Dim result As EntityCollection(Of DefGroupepaieEntity)

        Using adapter As New DatabaseSpecific.DataAccessAdapter
            Dim qf As New FactoryClasses.QueryFactory
            Dim q = qf.DefGroupepaie.Where(DefGroupepaieFields.Description.IsNull)

            result = CType(adapter.FetchQuery(q), EntityCollection(Of DefGroupepaieEntity))
        End Using

        Return result
    End Function

Can I force my code to use the extension.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 10-Dec-2014 20:25:09   

You are using the IsNull property not the function.

Try this: Dim q = qf.DefGroupepaie.Where(DefGroupepaieFields.Description.IsNull())

etilaf
User
Posts: 2
Joined: 10-Dec-2014
# Posted on: 10-Dec-2014 21:31:47   

I tried and it's not working maybe it's particular to VB. Can I do

    Public Function getData() As EntityCollection(Of DefGroupepaieEntity)
        Dim result As EntityCollection(Of DefGroupepaieEntity)

        Using adapter As New DatabaseSpecific.DataAccessAdapter
            Dim qf As New FactoryClasses.QueryFactory
            Dim q = qf.DefGroupepaie.Where(DefGroupepaieFields.Description = DBNull.Value)

            result = CType(adapter.FetchQuery(q), EntityCollection(Of DefGroupepaieEntity))
        End Using

        Return result
    End Function

instead ?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Dec-2014 07:15:32   

Yes, you can do it that way too. The IsNull() extension method should work however. It works on C#:

EntityCollection<OrderEntity> result = default(EntityCollection<OrderEntity>);

using (DatabaseSpecific.DataAccessAdapter adapter = new DatabaseSpecific.DataAccessAdapter())
{
    FactoryClasses.QueryFactory qf = new FactoryClasses.QueryFactory();
    var q = qf.Order.Where(OrderFields.ShipCountry.IsNull());

    result = (EntityCollection<OrderEntity>)adapter.FetchQuery<OrderEntity>(q);
}

... in VB.Net, it doesn't compile:

        Dim result As EntityCollection(Of OrderEntity)

        Using adapter As New DatabaseSpecific.DataAccessAdapter
            Dim qf As New FactoryClasses.QueryFactory
            Dim q = qf.Order.Where(OrderFields.ShipCountry.IsNull())

            result = CType(adapter.FetchQuery(q), EntityCollection(Of OrderEntity))
        End Using

... as per your compile error. We will look into it.

(Edit) Indeed it could be due to VB.Net incapacity to differentiate beetween a property and an extension method: http://msdn.microsoft.com/en-us/library/bb384936.aspx

The situation is simpler with properties: if an extension method has the same name as a property of the class it extends, the extension method is not visible and cannot be accessed.

(Edit) Workaround: call the extension method directly from the class it was created.

Dim q = qf.Order.Where(IsNullPredicateProducers.IsNull(OrderFields.ShipCountry))
David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 11-Dec-2014 10:59:56   

Hmm, didn't know that! Indeed, the direct call is the workaround here, vb.net being vb.net... rage

Frans Bouma | Lead developer LLBLGen Pro
omborddata
User
Posts: 42
Joined: 18-Apr-2012
# Posted on: 06-Apr-2018 15:21:19   

Otis wrote:

Hmm, didn't know that! Indeed, the direct call is the workaround here, vb.net being vb.net... rage

Maybe you should change the help docs to reflect this. I have been trying to use the IsNull function for a couple of hours today until I found this thread.

The section here needs to be adjusted for vb.net:

http://www.llblgen.com/documentation/5.0/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Filtering%20and%20Sorting/gencode_filteringpredicateclasses.htm#fieldcomparenullpredicate

And of course prev/later versions of llblgen also.

Thanks!

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 06-Apr-2018 15:37:04   

We'll see what we can do

Frans Bouma | Lead developer LLBLGen Pro