I Microsoft.SqlServer.Types.SqlGeography
. I fully understand that Linga's support for SQL is not very good. I have tried several methods, from the beginning, from the beginning ( Geography
, CLR type of SqlGeography
) would be the database type. It produces NotSupportedException
, which is widely discussed through the blog.
Then, as geography
column, verb (maximum)
, as geography
is a UDT form of binary Is stored in. It works fine (with some binary reading and writing extension methods).
However, now I am running in a very vague problem, which seems to have not happened to many other people.
System.InstallCastcast Exception: Unable to type 'Microsoft.SqlServer.Types.SqlGeography' type 'System.Byte []' to type.
This error is removed from a objectmatizerizer
via a query again. This only appears when tables containing geography columns are inserted into a query (such as using the code to insert EntityRef
).
System My question: If I'm retrieving the
Geography
column asvarbinary (max)
, then I Reverse error may be expected:Byte []
toSqlGeography
can not be inserted. I will understand that I do not let me have SQL classes from partial LINQ which hides binary conversion ... can this be the problem?Any help is appreciated, and I know that probably is not enough information.
Extra:
- A
Geography
column in Visual Studio DBML Designer with 'Server Data Type' =Geography
Generates this error:Specified type 'geography' is not a valid provider type.
- A
geography
with a 'server data type' in Visual Studio dbml designer generates this error:to execute as SQL The node 'value' could not be formatted.
Local type Linq is not supported by SQL I support "Great Is not "- it's not anybody.
You can read as a blob, but you can not do this by changing the column type from links to sql. You must change your questions at the database level to return the columns using the
CAST
statement as thevarbinary
statement. You can do this by adding a computedvarbinary
column to the table level, so that Linq is happily abyte []
., some DDLs like this:
ALTER TABLE FooTable ADD LocationData AS CAST (varbinary (max) as the location)
< / Pre>Then, use the
Delete Location
column from its Linux to the SQL class, and insteadLocationData .
If you need access to the actual
SqlGeography
example, you will need to change it in the byte array and change it and change it.You can add this process to a bit more "automated" partial Linux by adding up to the SQL unit square and adding an auto-convertible property:
public partial class Foo {public SqlGeography location {get {return SqlGeography.STGeomFromWKB (LocationData, 4326); } Set {LocationData = value.STAsBinary (); }}
It assumes that the
location data is the computed
varbinary
column name; If you do not include the "real"location
column in your SQL definition with SQL definition, then you can add it to ad hoc fashion above.Also keep in mind that you are able to do more than read and write this column; If you really ask about it (i.e. it's included in a
where
predicate), you will get the sameNot SupportedException
.
Comments
Post a Comment