guid

How to set null to a GUID property

百般思念 提交于 2019-11-29 03:19:08
I have an object of type Employee which has a Guid property. I know if I want to set to null I must to define my type property as nullable Nullable<Guid> prop or Guid? prop. But in my case I'm not able to change the type of the prop, so it will remains as Guid type and my colleague and I we don't want to use the Guid.Empty. Is there a way to set my property as null or string.empty in order to restablish the field in the database as null. I have a mechanism to transform from string.empty to null but I will change many things if the would change to accept a empty guid to null. Any help please!

GUID to ByteArray

ぐ巨炮叔叔 提交于 2019-11-29 02:56:30
I just wrote this code to convert a GUID into a byte array. Can anyone shoot any holes in it or suggest something better? public static byte[] getGuidAsByteArray(){ UUID uuid = UUID.randomUUID(); long longOne = uuid.getMostSignificantBits(); long longTwo = uuid.getLeastSignificantBits(); return new byte[] { (byte)(longOne >>> 56), (byte)(longOne >>> 48), (byte)(longOne >>> 40), (byte)(longOne >>> 32), (byte)(longOne >>> 24), (byte)(longOne >>> 16), (byte)(longOne >>> 8), (byte) longOne, (byte)(longTwo >>> 56), (byte)(longTwo >>> 48), (byte)(longTwo >>> 40), (byte)(longTwo >>> 32), (byte)

Find GUID From MSI File

我怕爱的太早我们不能终老 提交于 2019-11-29 01:53:08
How can I list the GUID of an installed program in Windows? Alternatively, is it easier to find the GUID if I have the MSI file? I'm looking through the MSI file with Orca but not sure where to look to find the GUID. Thanks! The three main GUIDs of a Windows Installer database are the Package Code , ProductCode , and UpgradeCode . The first is stored in the summary information stream (View menu in Orca), and the others are stored in the Property table. (Other forms of databases such as merge modules and patches have similar GUIDs in similar places, such as the merge module's GUID or the patch

GUID

不打扰是莪最后的温柔 提交于 2019-11-29 01:42:17
1、 <script> $(function(){ $('#AdminId').change(function(){ //var data= $(this).val(); var guid = new GUID(); $('#ApiId').val(guid.newGUID()); $('#ApiKey').val(guid.newGUID()); }); }); function GUID() { this.date = new Date(); /* 判断是否初始化过,如果初始化过以下代码,则以下代码将不再执行,实际中只执行一次 */ if (typeof this.newGUID != 'function') { /* 生成GUID码 */ GUID.prototype.newGUID = function () { this.date = new Date(); var guidStr = ''; sexadecimalDate = this.hexadecimal(this.getGUIDDate(), 16); sexadecimalTime = this.hexadecimal(this.getGUIDTime(), 16); for (var i = 0; i < 9; i++) { guidStr += Math.floor(Math.random() * 16)

Which part of a GUID is most worth keeping?

大城市里の小女人 提交于 2019-11-29 01:31:10
I need to generate a unique ID and was considering Guid.NewGuid to do this, which generates something of the form: 0fe66778-c4a8-4f93-9bda-366224df6f11 This is a little long for the string-type database column that it will end up residing in, so I was planning on truncating it. The question is: Is one end of a GUID more preferable than the rest in terms of uniqueness? Should I be lopping off the start, the end, or removing parts from the middle? Or does it just not matter? You can save space by using a base64 string instead: var g = Guid.NewGuid(); var s = Convert.ToBase64String(g.ToByteArray(

Why is the GUID structure declared the way it is?

安稳与你 提交于 2019-11-29 01:28:24
In rpc.h, the GUID structure is declared as follows: typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; BYTE Data[8]; } GUID; I understand Data1, Data2, and Data3. They define the first, second, and third sets of hex digits when writing out a GUID (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXX). What I never understood was why the last 2 groups were declared together in the same byte array. Wouldn't this have made more sense (and been easier to code against)? typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; WORD Data4; BYTE Data5[6]; } GUID; Anyone know why it is declared this way? It's

How many characters are there in a GUID?

我与影子孤独终老i 提交于 2019-11-29 00:48:23
Using ASCII encoding, how many characters are there in a GUID? I'm interested in the Microsoft style, which includes the curly brackets and dashes. From MSDN : A GUID is a 128-bit value consisting of one group of 8 hexadecimal digits, followed by three groups of 4 hexadecimal digits each, followed by one group of 12 hexadecimal digits. The following example GUID shows the groupings of hexadecimal digits in a GUID: 6B29FC40-CA47-1067-B31D-00DD010662DA From Wikipedia : Often braces are added to enclose the above format, as such: {3F2504E0-4F89-11D3-9A0C-0305E82C3301} So a total of 38 characters

How do you create a COM DLL in Visual Studio 2008?

被刻印的时光 ゝ 提交于 2019-11-28 23:20:29
问题 It's been ages since I've written a COM dll. I've made a couple of classes now, that inherit from some COM interfaces, but I want to test it out. I know I have to put a GUID somewhere and then register it with regsvr32, but what are the steps involved? Edit: Sorry, forgot to mention I'm using C++. 回答1: To create a new ATL COM project you can proceed as follow: File/New Project Visual C++/ATL/ATL Project Customize it settings, and press finish when done You have created a new dll, but it is

How do I use a guid in a mongodb shell query

爱⌒轻易说出口 提交于 2019-11-28 22:55:55
When using the MongoDB shell, how do I use a guid datatype (which I have used as the _id in my collection). The following format doesn't work: >db.person.find({"_id","E3E45566-AFE4-A564-7876-AEFF6745FF"}); Thanks. You have to compare the _id value against an instance of BinData (not against a string). Unfortunately the BinData constructor takes a Base64 string instead of a hex string. Your GUID value is missing two hex digits at the end, so for the purposes of this example I will assume they are "00". The following values are equivalent: hex: "E3E45566-AFE4-A564-7876-AEFF6745FF00" (ignoring

Nullable GUID

两盒软妹~` 提交于 2019-11-28 22:43:58
In my database, in one of the table I have a GUID column with allow nulls. I have a method with a Guid? parameter that inserts a new data row in the table. However when I say myNewRow.myGuidColumn = myGuid I get the following error: "Cannot implicitly convert type 'System.Guid?' to 'System.Guid'." The ADO.NET API has some problems when it comes to handling nullable value types (i.e. it simply doesn't work correctly). We've had no end of issues with it, and so have arrived at the conclusion that it's best to manually set the value to null, e.g. myNewRow.myGuidColumn = myGuid == null ? (object