Hello there,
We use Guids (RAW(16)) as primary keys for our tables, so far so good. EF4 also supports Guids properly.
However we are not satisfied with System.Guid type being a struct. Our classes have many relations which are optional, so this is effective waste of memory even if field is Nullable. We have many dictionaries which use Guid as a key, those dictionaries occupy lot of memory holding basically a copy of all Guids used as primary keys. If some wise guy from MS would make Guid a reference type, this would save a lots of memory and processing power.
Now add in this play WCF Data Services, where you cannot modify your EF-generated classes (because of hard-coded metadata publishing mechanism). So these Guids basically coming down to the Silverlight client, causing there the same memory and performance problems.
So my idea was to replace all Guids with String types in conceptual model, but to leave Guids in Storage model. Unfortunately, EF Designer complaints that this mapping is not possible.
Is it possible to make such a mapping possible?
I've done some tests: if EF doesn't really know that column is RAW(16), instead of VARCHAR2(32), saving and querying work fine. Trick is to write base64 encoded version of the guid in string field.
However, Guids loaded as string back look like 8 chinese symbols - no base64 decoding is taking place.
Any ideas how to get rid of Guids in conceptual model, but preserve them in DB?
Thank you in advance,
Alladin
Guid in Storage, but String in Conceptual
The new "raw guid as string" SSDL type will be added in the nearest build (this build will be released in a week or so).
This type is partially supported: Insert, Update, and Delete operations are supported. The Select queries with Where conditions containing this type like the or
are supported as well.
However, we cannot guarantee the correct handling of the LINQ Extension methods like or
This functionality is almost implemented, however, we have some questions regarding implementation details:
1. Is the default ('N') format "00000000000000000000000000000000" appropriate? Guid.ToString() uses the "00000000-0000-0000-0000-000000000000" ('D') format as the default one, but it is longer for 4 symbols.
2. Do you need the possibility to select the string representation format (i.e. select which of the 'N', 'D', 'B', 'P', 'X' formats to use for the string representation)?
3. What should be the empty string literal representation? Namely, in the query like the "" literal should be translated to null or to Guid.Empty("00000000-0000-0000-0000-000000000000")?
If you have any other propositions, please let us know.
This type is partially supported: Insert, Update, and Delete operations are supported. The Select queries with Where conditions containing this type like the
Code: Select all
context.RawTable.Where(rawTable => rawTable.RawColumn == "D3BC058453DC43CCB7C542D8345388FD")
Code: Select all
string value = "D3BC058453DC43CCB7C542D8345388FD";
context.RawTable.Where(rawTable => rawTable.RawColumn == value)
However, we cannot guarantee the correct handling of the LINQ Extension methods like
Code: Select all
context.RawTable.Where(rawTable => rawTable.RawColumn.Contains("DC43CCB7C542"))
Code: Select all
context.RawTable.Where(rawTable => rawTable.RawColumn.IndexOf("DC43CCB7C542") > 0)
1. Is the default ('N') format "00000000000000000000000000000000" appropriate? Guid.ToString() uses the "00000000-0000-0000-0000-000000000000" ('D') format as the default one, but it is longer for 4 symbols.
2. Do you need the possibility to select the string representation format (i.e. select which of the 'N', 'D', 'B', 'P', 'X' formats to use for the string representation)?
3. What should be the empty string literal representation? Namely, in the query like
Code: Select all
context.RawTable.Where(raw => raw.RawColumn == "")
If you have any other propositions, please let us know.
New build of dotConnect for Oracle 6.30.196 is available for download!
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21605 .
It can be downloaded from http://www.devart.com/dotconnect/oracle/download.html (trial version) or from Registered Users' Area (for users with valid subscription only): http://secure.devart.com/ .
For more information, please refer to http://www.devart.com/forums/viewtopic.php?t=21605 .