none
Oracle RAW(16) returned as byte[] with ObjectContext ExecuteStoreQuery RRS feed

  • Question

  • Hi, I have an object model with C# Guids mapped to RAW(16) Oracle Fields.

    I try to execute a SELECT query with ObjectContext ExecuteStoreQuery method but it returns the errore:

    An exception of type 'System.InvalidOperationException' occurred in System.Data.Entity.dll but was not handled in user code
    Additional information: The 'dbNewsID' property on 'News' could not be set to a 'Byte[]' value. You must set this property to a non-null value of type 'Guid'.

    The code is like following:

    News news = Context.ExecuteStoreQuery<News>(@"select uidnews ""dbNewsID"", codnews ""dbNewsCode"", destitle ""dbTitleDescription"" from NewsTable where rownum = 1").ToList().FirstOrDefault();

    Where News is the C# class were dbNewsID is a Guid and NewsTable is the Oracle Table where uidnews is a RAW(16) primary key.

    Is it possible to execute this query without changing the Guid mapping?

    PS: I'm connecting to Oracle with provider Oracle.ManagedDataAccess.Client

    Thanks,
    Sandro


    Thursday, October 25, 2018 2:47 PM

All replies

  • You can probably add a byte[] field for uidnews, then create a Guid property for dbNewsID getting and setting value for it.

    Modify your TT template so it generates "partial" class for the entities instead.

    Something like the following:

        public partial class News
        {
            public Guid dbNewsID
            {
                get { return new Guid(this.uidnews); }
                set { this.uidnews = value.ToByteArray(); }
            }
        }

    Friday, October 26, 2018 1:58 AM
    Answerer