Im working with IBM DB2 and there is no GUID(uniqueidentifier) datatype there. Instead there is char for binary. When i create entity database model from that database- that type is identified as byte[] in the model. When i use model directly with database-everything works just fine(accepts Guid.NewGuid().ToByteArray()
as primary key/entity key), but i MUST use service layer. So i have chosen WCF Data Service model for the layer and added same databa开发者_Python百科se model there. After trying to add service reference i keep getting error:
Does that mean that there is no way i can use tables with binary as PK?
PS by the way about datatypes in DB2: what do you suggest me to use in db2 to allow simple copying data from one table to another between different db servers?
DB2 allows binary data in smaller columns that can also serve as unique keys, but you'll have to assign the unique ID either as part of the INSERT statement or from a trigger. The FOR BIT DATA qualifier is used in the CREATE TABLE statement to tell DB2 that the CHAR or VARCHAR column you've defined will store binary values.
DB2's internal unique function is called GENERATE_UNIQUE() and it returns a CHAR(13) FOR BIT DATA value that is guaranteed to be unique within the database (both on single-partition DB2 servers, and InfoSphere Warehouse clustered DB2 databases). If you want to store larger GUIDs that come from a layer outside the DBMS, you should be able to store them in a CHAR/VARCHAR FOR BIT DATA COLUMN.
精彩评论