This is a migrated thread and some comments may be shown as answers.

Directly parameterized literal boolean eq/neq expression found AGAIN

1 Answer 79 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Igor
Top achievements
Rank 1
Igor asked on 28 Dec 2011, 01:01 PM

Hi
I try rewrite some code with yours Fluent API (with 2011.3.1213.3 on MS SQL Server).
My test code  ...

CREATE TABLE [dbo].[_AldaAppOptions2](

      [oID] [uniqueidentifier] ROWGUIDCOL  NOT NULL,

      [Key] [nvarchar](max) NOT NULL,

      [Value] [ntext] NULL,

      [ValueType] [nvarchar](max) NULL,

      [Version] [int] NOT NULL,

      [TimeStamp] [datetime] NOT NULL,

 CONSTRAINT [PK__AldaAppOptions2] PRIMARY KEY CLUSTERED

(

      [oID] ASC

)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]

) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]



    public class AppOptions

    {

             public Guid oID { get; set; }

             public string Key { get; set; }

             public string Value { get; set; }

             public string ValueType { get; set; }

             public int Version { get; set; }

             public DateTime TimeStamp { get; set; }

    }

   public class AppOptionsMetadataSource : FluentMetadataSource

    {

        protected override IList<MappingConfiguration> PrepareMapping()

        {

            // Getting Started with the Fluent Mapping API

            // http://www.telerik.com/help/openaccess-orm/fluent-mapping-overview.html

            List<MappingConfiguration> configurations = new List<MappingConfiguration>();

            MappingConfiguration<AppOptions> appOptionsConfiguration = new MappingConfiguration<AppOptions>();

            appOptionsConfiguration.MapType(x => new

            {

                oID = x.oID,

                Key = x.Key,

                Value = x.Value,

                ValueType = x.ValueType,

                Version = x.Version,

                TimeStamp = x.TimeStamp,

            }).ToTable("_AldaAppOptions2");

            appOptionsConfiguration.HasProperty(x => x.oID).IsIdentity(KeyGenerator.Guid);

            configurations.Add(appOptionsConfiguration);

            return configurations;

        }

    }

    class Program

    {

        static void Main(string[] args)

        {

            try

            {

                var connectionInfo = DbConnection.ConnectionInfo.Load();

                if (connectionInfo == null)

                    throw new ArgumentNullException("connectionInfo");

                var context = new AppOptionsContext(connectionInfo);

                {

                    var majorVersion = 1 << 24;

                    var options = context.AppOptions.Where((a) => (a.Version & 0x7000000) == majorVersion);

                    foreach (var rec in options)

                    {

                        Debug.WriteLine(rec.Key + "  " + rec.Value);

                    }

                }

                Console.ReadKey();

            }

            catch (Exception ex)

            {

                Debug.WriteLine(ex);

            }

        }

}

Error …

DbConnectionProvider List CLR=v2.0.50727 32bit

'System.Data.Odbc' => 'System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

'System.Data.OleDb' => 'System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

'System.Data.OracleClient' => 'System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

'System.Data.SqlClient' => 'System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

'System.Data.SqlServerCe.3.5' => 'System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91'

'Alda.OpenAccess.AppOptions.ConsoleTest.vshost.exe' (Managed (v2.0.50727)): Loaded 'C:\Windows\assembly\GAC_MSIL\WindowsBase\3.0.0.0__31bf3856ad364e35\WindowsBase.dll'

A first chance exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.dll

A first chance exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.Runtime.dll

A first chance exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.dll

A first chance exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.35.Extensions.dll

A first chance exception of type 'System.InvalidOperationException' occurred in Telerik.OpenAccess.35.Extensions.dll

System.InvalidOperationException: An exception occured during the execution of '

Extent<Alda.OpenAccess.AppOptions.AppOptions>().Where(a => ((a.Version & 117440512) = value(Alda.OpenAccess.AppOptions.ConsoleTest.Program+<>c__DisplayClass0).majorVersion))'.

Failure: Directly parameterized boolean eq/neq expression found for 'AndNode eq/neq ParamNodeProxy'.

 ---> Telerik.OpenAccess.OpenAccessException: Directly parameterized boolean eq/neq expression found for 'AndNode eq/neq ParamNodeProxy'.

   в Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQueryImpl(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)

   в Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)

   --- Конец трассировки внутреннего стека исключений ---

   в Telerik.OpenAccess.Query.ExpressionCompiler.PerformDatabaseQuery(Type type, Int32 elementAt, Object[] groupResolutionParamValues, Boolean single, Boolean checkOid)

   в Telerik.OpenAccess.Query.ExpressionExecution.PerformDatabaseQueryMulti[T](Expression expr, ExecutionSettings settings, Object[] grpVals, Boolean checkOid)

   в Telerik.OpenAccess.Query.Piece`1.ExecuteMultiple()

   в Telerik.OpenAccess.Query.Piece`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()

   в Alda.OpenAccess.AppOptions.ConsoleTest.Program.Main(String[] args) в D:\Development\svn.dev.net\Configuration\Alda.OpenAccess.AppOptions.ConsoleTest\Program.cs:строка 20


1 Answer, 1 is accepted

Sort by
0
Serge
Telerik team
answered on 30 Dec 2011, 10:20 AM
Hi,

 Unfortunately pushing bitwise operations trough a LINQ query to the server is not currently supported and this is why you get such an exception, that I agree can (and will) be improved. I am sorry to disappoint you, however the only workaround at the moment would be to either implement arithmetic checks or retrieve the whole subset using ToList() and do the filtering operation in-memory. 

I hope this helps. Please do not hesitate to let us know should you face further trouble.  

Kind regards,
Serge
the Telerik team

Q3’11 of Telerik OpenAccess ORM is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
LINQ (LINQ specific questions)
Asked by
Igor
Top achievements
Rank 1
Answers by
Serge
Telerik team
Share this question
or