SQL Server 2012 - Microsoft.SqlServer.Types 11.0.0.0

7 posts, 1 answers
  1. Chuck
    Chuck avatar
    30 posts
    Member since:
    Sep 2010

    Posted 19 May 2012 Link to this post

    I am using the current version of the ORM (2012.1.301.2).  In my project I reference the Microsoft.SqlServer.Types.dll.  Everything still works as expected on my machine which has both SQL Server 2012 & SQL Server 2008 installed when I use the old version of the dll (10.0.0.0) referencing a SQL Server 2012 database.  But when I switch to the new version (Microsoft.SqlServer.Types.dll v. 11.0.0.0) I get the following error from the ORM:

    No AdoTypeConverter has been registered for the clrType.
    Parameter name: clrType
    Actual value was Microsoft.SqlServer.Types.SqlGeometry.

    I assume that on a clean install with only SQL Server 2012, the preferred dll will reference version 11.0.0.0, as 10.0.0.0 may not be available without some kind of backwards compatability.  Any thoughts on this?
  2. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 23 May 2012 Link to this post

    Hi Chuck,

    Can you please try to generate a SqlGeometry type in your application before any Context is loaded? This would ensure that the respective dll is loaded and the TypeConverter can handle this type.

    I hope this information is useful for you.
    Feel free to ask if you have any other question.

    Greetings,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
  4. Chuck
    Chuck avatar
    30 posts
    Member since:
    Sep 2010

    Posted 23 May 2012 Link to this post

    I am declaring the type prior to loading the Context, unless I totally don't understand what you mean.  I created a simple sample project to duplicate the issue.  I have replicated this in both VS2008 (using .Net 2.0) and VS2010 (using .Net 4.0).  Here is sample code that causes the issue:
    Dim g As New Microsoft.SqlServer.Types.SqlGeometry

    Using x
    As New EntitiesModel
     
         Dim p As IQueryable(Of WorkRequest) = _
             From workrequest1 In x.WorkRequests _
             Join workrequestgeometry In x.WorkRequestGeometries _
             On workrequest1 Equals WorkRequestGeometry.WorkRequest _
             Where WorkRequestGeometry.ShapeWeb.STIntersects(g).Equals(1) _
             Take (3) _
             Select workrequest1
     
         Dim l As List(Of WorkRequest) = p.ToList
      
     End Using

    When I reference Microsoft.SqlServer.Types.dll version 10.0.0.0 it works (no results returned because I did not initialize the geometry in this sample, but it works in production just fine).

    When I reference Microsoft.SqlServer.Types.dll 11.0.0.0 it throws the exception above.
  5. Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 25 May 2012 Link to this post

    Hello Chuck,

    I tried to reproduce the behavior you described with the attached project but without success. I was using the latest internal build (2012.1.427.1) and referenced Microsoft.SqlServer.Types Version 11.
    Have you also tried the latest internal build? If not, could you please try it? Is the attached sample application running in your environment (using the latest internal build)?

    I am looking forward to hearing from you soon.

    All the best,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  6. Chuck
    Chuck avatar
    30 posts
    Member since:
    Sep 2010

    Posted 25 May 2012 Link to this post

    Thank you for looking at this in depth.  I think you were unable to reproduce the behavior because you stopped short of running the actual spatial query.  The code you provided works on my system without installing the internal build, but please follow it with the following query:

    (VB.Net)

    Using ctx As New EntitiesModel
     
        Dim geo As New _SpatialTable
     
        Dim polygon As String = "POLYGON((0 0,0 8,8 8,8 4,4 4,4 0,0 0))"
        Dim sqlgeo As Microsoft.SqlServer.Types.SqlGeometry = Microsoft.SqlServer.Types.SqlGeometry.STGeomFromText(New System.Data.SqlTypes.SqlChars(polygon), 0)
        geo.GeomCol1 = sqlgeo
     
        ctx.Add(geo)
        ctx.SaveChanges()
     
        Dim geos As List(Of _SpatialTable) = ctx._SpatialTables.ToList()
     
                'The following 2 lines of codes contain the issue
        Dim p As IQueryable(Of _SpatialTable) = _
            From st In ctx._SpatialTables
            Where st.GeomCol1.STIntersects(sqlgeo).Equals(1)
     
        Dim geos2 As List(Of _SpatialTable) = p.ToList
     
    End Using
  7. Answer
    Ralph Waldenmaier
    Admin
    Ralph Waldenmaier avatar
    202 posts

    Posted 25 May 2012 Link to this post

    Hello Chuck,

    Thank you again. No I am also able to see the reported exception. The problem only occurs if you pass parameters to queries that are of the version 11 type. There we are currently not able to get the appropriate TypeConverter. For queries without parameters, we are able to detect the correct type while providing the result, because we can use the column type to calculate the appropriate TypeConverter.
    Unfortunately, the only workaround for you at the moment is, to hard link against the version 10 dll.
    I have added this issue to our backlog to provide a solution for that in the future.

    Again thank you for pointing this out.
    Feel free to ask if you have any other question.

    Greetings,
    Ralph
    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  8. Chuck
    Chuck avatar
    30 posts
    Member since:
    Sep 2010

    Posted 25 May 2012 Link to this post

    Thank you.  I know you guys will get it working!
Back to Top
DevCraft banner