Invalid casting Primary and Foreign Keys after using ROWID as a primary keys

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
dqrest
Posts: 32
Joined: Tue 15 Sep 2015 06:01

Invalid casting Primary and Foreign Keys after using ROWID as a primary keys

Post by dqrest » Mon 12 Oct 2020 13:02

Hello!

I have dotConnect for Oracle 9.13.1098 (trial).
In order to avoid of using nullable values in primary key fields I add ROWID as a primary key, but I have problems in assosiations between child and parent entites. Namely, there are problems in casting System.Int64 to System.String.

I have two classes in C#:

Code: Select all

[Table(Name = "TABLE1")]
    public class TdfBlock
    {
        long _No;
        //[Column(Name = "NO", Storage = "_No", IsPrimaryKey = true)]
        [Column(Name = "NO", Storage = "_No")]
        public long No { get { return _No; } }

        string _Rowid;
        [Column(Name = "ROWID", Storage = "_Rowid", IsPrimaryKey = true)]
        public string Rowid { get { return _Rowid; } }
        

        EntitySet<TypeTreeMapping.BaseClasses.Kernel.T51.TdfField> _ES_TdfFields_BlockNo = new EntitySet<TypeTreeMapping.BaseClasses.Kernel.T51.TdfField>();       
        [Association(OtherKey = "BlockNo", Storage = "_ES_TdfFields_BlockNo")]
        public EntitySet<TypeTreeMapping.BaseClasses.Kernel.T51.TdfField> ES_TdfFields_BlockNo { get { return _ES_TdfFields_BlockNo; } }
    }

Code: Select all

 [Table(Name = "TABLE2")]
    public class TdfField
    {
        //long _No;
        ////[Column(Name = "NO", Storage = "_No"]
        //[Column(Name = "NO", Storage = "_No", IsPrimaryKey = true)]
        //public long No { get { return _No; } }

        string _Rowid;
        [Column(Name = "ROWID", Storage = "_Rowid", IsPrimaryKey = true)]
        public string Rowid { get { return _Rowid; } }

        long? _BlockNo;
        ///<summary>Номер блока, в котором содержится поле</summary>
        [Column(Name = "BLOCK_NO", Storage = "_BlockNo")]
        public long? BlockNo { get { return _BlockNo; } }

        
        EntityRef<TypeTreeMapping.BaseClasses.Kernel.T50.TdfBlock> _ER_BlockNo_50;       
        [Association(ThisKey = "BlockNo", Storage = "_ER_BlockNo_50")]
        public TypeTreeMapping.BaseClasses.Kernel.T50.TdfBlock E_BlockNo_50
        {
            get
            {                
                return _ER_BlockNo_50.Entity;
            }
        }
    }
After getting the property E_BlockNo_50 in the class TdfField I have the error "Не удалось привести тип объекта "System.Int64" к типу "System.String".".

Has anybody solves this problem?

dqrest
Posts: 32
Joined: Tue 15 Sep 2015 06:01

Re: Invalid casting Primary and Foreign Keys after using ROWID as a primary keys

Post by dqrest » Tue 13 Oct 2020 10:16

Devart team, can you catch this issue?

dqrest
Posts: 32
Joined: Tue 15 Sep 2015 06:01

Re: Invalid casting Primary and Foreign Keys after using ROWID as a primary keys

Post by dqrest » Tue 13 Oct 2020 12:01

The problem is apperead as follows.
The class TdfField has a foreign key from the field "BlockNo" to the primary key "RowId" of the class "TdfBlock".

dqrest
Posts: 32
Joined: Tue 15 Sep 2015 06:01

Re: Invalid casting Primary and Foreign Keys after using ROWID as a primary keys

Post by dqrest » Wed 14 Oct 2020 06:36

The problem has been solved by adding ThisKey and OtherKey in all association attributes. Thanks!

Post Reply