Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support: DbGeography #93

Open
lastlink opened this issue Jul 8, 2016 · 2 comments
Open

support: DbGeography #93

lastlink opened this issue Jul 8, 2016 · 2 comments

Comments

@lastlink
Copy link

lastlink commented Jul 8, 2016

Bulk insert of lat/long as a 'DbGeography' type throws an error. Is this just not supported?

@smithkl42
Copy link

If you change the EFDataReader.GetValue() method to this, it works, at least in SQL Server (though it breaks the provider architecture - the translation from DbGeo** to SqlGeo** should happen somewhere else):

    public override object GetValue(int ordinal)
    {
        object value = Accessors[ordinal](Enumerator.Current);

        var dbgeo = value as DbGeography;
        if (dbgeo != null)
        {
            var chars = new SqlChars(dbgeo.WellKnownValue.WellKnownText);
            return SqlGeography.STGeomFromText(chars, dbgeo.CoordinateSystemId);
        }

        var dbgeom = value as DbGeometry;
        if (dbgeom != null)
        {
            var chars = new SqlChars(dbgeom.WellKnownValue.WellKnownText);
            return SqlGeometry.STGeomFromText(chars, dbgeom.CoordinateSystemId);
        }

        return value;
    }

@smithkl42
Copy link

@MikaelEliasson - BTW, happy to throw together a patch for the current active version. I took a look at the V2 you're working on, and it looks like it might be a while before a patch landed there would be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants