guid

Is there any way to create a short unique code like short GUID?

北城以北 提交于 2019-12-03 01:12:48
I want to create a short GUID. Is there any way to create a short unique code like short GUID? I want to create a ticket tracking number. JKhuang The length of GUID is 128bits(16bytes), so if you want to create a short GUID , you have to change GUID's encoding. For instance, you can user base64 or ASCII85. /// <summary> /// Creates a GUID which is guaranteed not to equal the empty GUID /// </summary> /// <returns>A 24 character long string</returns> public static string CreateGuid() { Guid guid = Guid.Empty; while (Guid.Empty == guid) { guid = Guid.NewGuid(); } // Uses base64 encoding the guid

[UWP]: Alarm notification audio when system volume is set to off

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi all :) We are coding an app for the local fire departements since they plan to remove one of two pager frequencies and replace it with an app (they have two alert channels then, classic pager and mobile phone). In case of an incoming alert, the phone creates an alarm-scenario ToastNotification with audio. So far so good, the problem is that the audio file isn't played if the user has set the system master volume to zero. I know it's not possible so far to change the system volume from an app, but for my scenario I need to play the audio

YouTube-like GUID

匿名 (未验证) 提交于 2019-12-03 01:06:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to generate short GUID like in YouTube (N7Et6c9nL9w)? How can it be done? I want to use it in web app. 回答1: You could use Base64: string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); That generates a string like E1HKfn68Pkms5zsZsvKONw== . Since a GUID is always 128 bits, you can omit the == that you know will always be present at the end and that will give you a 22 character string. This isn't as short as YouTube though. 回答2: 9 chars is not a Guid. Given that, you could use the hexadecimal representation

Int PK inner join Vs Guid PK inner Join on SQL Server. Execution plan

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I just did some testing for Int PK join Vs Guid PK. Tables structure and number of records looking like that: Performance of CRUD operations using EF4 are pretty similar in both cases. There is well known statement that Int PK has better performance rather than strings when used in joins. So SQL server execution plan with INNER JOINS are completely different Here is an execution plan: As i understand according with execution plan from above Int join has better performance because it is taking less resources for Clustered index scan and it is

Guid.NewGuid() vs. new Guid()

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What's the difference between Guid.NewGuid() and new Guid() ? Which one is preferred? 回答1: new Guid() makes an "empty" all-0 guid (00000000-0000-0000-0000-000000000000 is not very useful). Guid.NewGuid() makes an actual guid with a unique value, what you probably want. 回答2: Guid.NewGuid() creates a new UUID using an algorithm that is designed to make collisions very, very unlikely. new Guid() creates a UUID that is all-zeros. Generally you would prefer the former, because that's the point of a UUID (unless you're receiving it from somewhere

What are the performance improvement of Sequential Guid over standard Guid?

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Has someone ever measured performance of Sequential Guid vs. Standard Guid when used as Primary Keys inside a database? 回答1: GUID vs.Sequential GUID A typical pattern it's to use Guid as PK for tables, but, as referred in other discussions (see Advantages and disadvantages of GUID / UUID database keys ) there are some performance issues. This is a typical Guid sequence f3818d69-2552-40b7-a403-01a6db4552f7 7ce31615-fafb-42c4-b317-40d21a6a3c60 94732fc7-768e-4cf2-9107-f0953f6795a5 Problems of this kind of data are: - Wide distributions of

FreeSql (十七)联表查询

匿名 (未验证) 提交于 2019-12-03 00:08:02
FreeSql在查询数据下足了功能,链式查询语法、多表查询、表达式函数支持得非常到位。 IFreeSql fsql = new FreeSql.FreeSqlBuilder() .UseConnectionString(FreeSql.DataType.MySql, "Data Source=127.0.0.1;Port=3306;User ID=root;Password=root;Initial Catalog=cccddd;Charset=utf8;SslMode=none;Max pool size=10") .Build(); [Table(Name = "tb_topic")] class Topic { [Column(IsIdentity = true, IsPrimary = true)] public int Id { get; set; } public int Clicks { get; set; } public int TestTypeInfoGuid { get; set; } public TestTypeInfo Type { get; set; } public string Title { get; set; } public DateTime CreateTime { get; set; } } class TestTypeInfo {

C# Lambda 表达式 (小记)

匿名 (未验证) 提交于 2019-12-02 23:49:02
在lambda 表达式中经常会用到 FindAll() 、Find() 、Where() 、 Select()等 这些虽然都可以取出数据但是还是有一些不同的 List<MyClass> list = new List<MyClass>() { new MyClass {Name = "张三",index = 1,Guid = new Guid()}, new MyClass{Name ="李四",index=2,Guid=new Guid()}, new MyClass{Name ="王五",index=2,Guid=new Guid()}, new MyClass{Name ="赵六",index=3,Guid=new Guid()} }; for (int i = 0; i < list.Count; i++) { Console.WriteLine(list[0].Guid); } var User = from I in list select I; var Info = list.OrderByDescending(n => n.index);// 根据index 倒序 var Info1 = list.FindAll(i => i.index == 2);//查找出所有index =2 的 var Info2 = list.Find(i => i.index == 2)

Windows USB 编程

匿名 (未验证) 提交于 2019-12-02 23:26:52
GUID #include <initguid.h> // For DEFINE_GUID // Device Interface GUID. DEFINE_GUID(GUID_DEVINTERFACE_FOR_D3XX, GUID DeviceGUID[2] = {0}; GUID是通过特定算法产生的一个二进制长度为128位的数字,在空间上和时间上具有唯一性,保证同一时间不同地方产生的数字不同。GUID的主要目的是产生完全唯一的数字。在理想情况下,任何计算机和计算机集群都不会生成两个相同的GUID。随机生成两个相同GUID的可能性是非常小的,但并不为0。   用了DEFINE_GUID,你可以使用在所有源文件中包含同一个头文件,在头文件中这样定义GUID:DEFINE_GUID(CLSID_MyObject,0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);   在没有包含Initguid.h的地方,DEFINE_GUID宏创建外部引用来使用GUID值,在包含Initguid.h的地方,DEFINE_GUID重定义DEFINE_GUID宏以产生GUID的定义。 typedef struct _GUID { unsigned long Data1; unsigned short