简体   繁体   中英

oracle mdsys.vertex_set_type custom mapping c#

i am developing ac# application which works with oracle database. i am using oracle.dataaccess provider. but when i try to run this query:

select sdo_util.getVertices(sdo_geom.sdo_intersection(geo1,geo2,0.005))
from geotable1
where sdo_anyinteract(geo1,geo2) = 'TRUE' and id1 = 59

The ID number is only for example. The result of this query is per Oracle specification MDSYS.VERTEX_SET_TYPE, which consists of a table of objects of VERTEX_TYPE.

and this is the first problem. when i try to run this query by oracle.dataaccess provider, i get error "Custom type mapping for 'dataSource='...' schemaName='MDSYS' typeName='VERTEX_SET_TYPE'' is not specified or is invalid. I have searched for solution, which should implement this custom mapping, but without success.

So i tried to implement this by me. This is the code:

[OracleCustomTypeMappingAttribute("MDSYS.VERTEX_SET_TYPE")]
public class VertexSetType : OracleCustomTypeBase<VertexSetType>
{

    private enum OracleObjectColumns { VERTEX_TYPE }

    private List<VertexType> vertexType;

    [OracleObjectMappingAttribute(0)]
    public List<VertexType> VertexType
    {
        get { return vertexType; }
        set { vertexType = value; }
    }

    public override void MapFromCustomObject()
    {
        SetValue((int)OracleObjectColumns.VERTEX_TYPE, VertexType);
    }

    public override void MapToCustomObject()
    {
        VertexType = GetValue<List<VertexType>>((int)OracleObjectColumns.VERTEX_TYPE);
    }
}

The VertexType i have defined as:

[OracleCustomTypeMappingAttribute("MDSYS.VERTEX_TYPE")]
public class VertexType : OracleCustomTypeBase<VertexType>
{

    private enum OracleObjectColumns { X, Y, Z, W, ID }

    private decimal? x;

    [OracleObjectMappingAttribute(0)]
    public decimal? X
    {
        get { return x; }
        set { x = value; }
    }

    private decimal? y;

    [OracleObjectMappingAttribute(0)]
    public decimal? Y
    {
        get { return y; }
        set { y = value; }
    }

    private decimal? z;

    [OracleObjectMappingAttribute(0)]
    public decimal? Z
    {
        get { return z; }
        set { z = value; }
    }

    private decimal? w;

    [OracleObjectMappingAttribute(0)]
    public decimal? W
    {
        get { return w; }
        set { w = value; }
    }

    private decimal? id;

    [OracleObjectMappingAttribute(0)]
    public decimal? Id
    {
        get { return id; }
        set { id = value; }
    }

    public override void MapFromCustomObject()
    {
        SetValue((int)OracleObjectColumns.X, x);
        SetValue((int)OracleObjectColumns.Y, y);
        SetValue((int)OracleObjectColumns.Z, z);
        SetValue((int)OracleObjectColumns.W, w);
        SetValue((int)OracleObjectColumns.ID, id);
    }

    public override void MapToCustomObject()
    {
        X = GetValue<decimal?>((int)OracleObjectColumns.X);
        Y = GetValue<decimal?>((int)OracleObjectColumns.Y);
        Z = GetValue<decimal?>((int)OracleObjectColumns.Z);
        W = GetValue<decimal?>((int)OracleObjectColumns.W);
        Id = GetValue<decimal?>((int)OracleObjectColumns.ID);
    }

}

but when i run the query againg, i get the error:

Unable to cast object of type 'spatial.VertexSetType' to type 'Oracle.DataAccess.Types.IOracleArrayTypeFactory'.

I cannot move forward from this situation because of very less c# custom mapping of oracle data types.. So please, if someone should help, i would really appreciate it. Thanks.

Never mind, I have fixed it by me. The MDSYS.VERTEX_SET_TYPE should be defined as simple Oracle Array, containing VertexType objects.

[OracleCustomTypeMappingAttribute("MDSYS.VERTEX_SET_TYPE")]
public class VertexSetType : OracleArrayTypeFactoryBase<VertexType> { }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM