guid

Converting System.Decimal to System.Guid

半世苍凉 提交于 2019-11-26 23:21:42
问题 I have a big dictionary where the key is decimal, but the GetHashCode() of System.Decimal is disasterously bad. To prove my guess, I ran a for loop with 100.000 neigboring decimals and checked the distribution. 100.000 different decimal numbers used only 2 (two!!!) different hashcodes. Decimal is represented as 16 bytes. Just like Guid! But the GetHashCode() distribution of Guid is pretty good. How can I convert a decimal to Guid in C# as cheap as possible? Unsafe code is OK! EDIT: The test

Wix generate single component id for entire tree

回眸只為那壹抹淺笑 提交于 2019-11-26 23:04:28
I am someone with little to no experience with wix and I am trying to support Windows also for the component I am responsible for. I am trying to create merge module for a set of files that my product generates. These files exist in numerous sub directories. I was wondering how I can create a single component ID for all the files in the entire tree. I am not worried about minor upgrades as that is something I am not going to be doing. I am trying to avoid generating numerous GUIDs for each of the file. Also is there any way I can change the name of the root directory I want the files to be

GUID COMB strategy in EF

回眸只為那壹抹淺笑 提交于 2019-11-26 22:46:57
Is there any way to implement the Guid COMB identity strategy for objects in the new Entity Framework 4.1 using the CodeFirst design? I thought setting the StoreGeneratedPattern would work, but it still gives me normal GUIDs. I guess you are using SQL server as your database. This is nice example of inconsistency among different MS tools. SQL server team doesn't recommend using newid() as default value for UNIQUEIDENTIFIER columns and ADO.NET team use it if you specify Guid property as autogenerated in the database. They should use newsequentialid() instead! If you want sequential Guids

Convert from Oracle's RAW(16) to .NET's GUID

帅比萌擦擦* 提交于 2019-11-26 22:38:18
问题 I'm having difficulties manually debugging an .NET application where the Guid values differ from .NET to Oracle. Where C# reads: 17D89D326C2142D69B989F5201288DBF Oracle reads: 329DD817216CD6429B989F5201288DBF How would I be able to manually debug, i.e., from C#'s GUID be able to paste that value in an oracle query and get the correct results (and viceversa)? 回答1: If you look at the values involved (in pairs) of hex digits you can see that the last 7 bytes are the same in both cases, but the

C# guid and SQL uniqueidentifier

ⅰ亾dé卋堺 提交于 2019-11-26 22:05:44
I want to create a GUID and store it in the DB. In C# a guid can be created using Guid.NewGuid(). This creates a 128 bit integer. SQL Server has a uniqueidentifier column which holds a huge hexidecimal number. Is there a good/preferred way to make C# and SQL Server guids play well together? (i.e. create a guid using Guid.New() and then store it in the database using nvarchar or some other field ... or create some hexidecimal number of the form that SQL Server is expecting by some other means) SQL is expecting the GUID as a string. The following in C# returns a string Sql is expecting. "'" +

How to predict the next GUID from a given GUID?

拟墨画扇 提交于 2019-11-26 21:59:15
问题 I have sent 10000 mails to our customers and each mail had a link of the format http://example.com/LogIn?key={guid} Unfortunately the guid I sent were random guids (test data generated by Guid.NewGuid() ) so the customers have all received invalid links... Based on the 404s i receive from the webserver I have a few guids that I sent out. I have read that the guid generator in windows is weak so you can predict the next guid from one you already have. Does anyone know how? If i could do that I

SSIS: Filtering Multiple GUIDs from String Variable as Parameter In Data Flow OLE Source

拈花ヽ惹草 提交于 2019-11-26 21:46:17
问题 I have an SSIS package that obtains a list of new GUIDs from a SQL table. I then shred the GUIDs into a string variable so that I have them separated out by comma. An example of how they appear in the variable is: '5f661168-aed2-4659-86ba-fd864ca341bc','f5ba6d28-7283-4bed-9f11-e8f6bef225c5' The problem is in the data flow task. I use the variable as a parameter in a SQL query to get my source data and I cannot get my results. When the WHERE clause looks like: WHERE [GUID] IN (?) I get an

Are automatically generated GUIDs for types in .NET consistent?

↘锁芯ラ 提交于 2019-11-26 20:51:54
问题 Are the automatically generated GUIDs for C# Types consistent? For example, if I get a GUID for my interface, IFoo ( typeof(IFoo).GUID ), the first time a run the program, will I get that same GUID everytime I run the program? I have tested it locally on my machine, and it seems to always be the same, but I'm not sure if I can rely on it always being the same across machines. 回答1: See: System.Type.GUID stability. It appears that the current implementation of the method relies an internal call

Guid == null should not be allowed by the compiler

主宰稳场 提交于 2019-11-26 20:35:28
问题 The behaviour described below is specific to .net-3.5 only I just ran across the most astonishing behavior in the C# compiler; I have the following code: Guid g1 = Guid.Empty; bool b1= (g1 == null); Well, Guid is not nullable therefore it can never be equal to null . The comparison i'm making in line 2 always returns false . If you make the same thing for an integer, the compiler issues an warning saying the result will always be false: int x=0; bool b2= (x==null); My question is: Why does

How are .NET 4 GUIDs generated?

社会主义新天地 提交于 2019-11-26 20:22:55
I am aware of the multitude of questions here as well as Raymond's excellent (as usual) post . However, since the algorithm to create GUIDs was changed apparently, I found it hard to get my hands on any up-to-date information. The MSDN seems to try and provide as few information as possible. What is known about how GUIDs are generated in .NET 4? What was changed, and how does it affect the security ("randomness") and integrity ("uniqueness")? One specific aspect I'm interested in: In v1, it seems to be about impossible to generate the same GUID on a single machine again since there was a