guid

SQL GUID Vs Integer

徘徊边缘 提交于 2019-12-03 02:20:29
I have recently started a new job and noticed that all the SQL tables use the GUID data type for the primary key. In my previous job we used integers (Auto-Increment) for the primary key and it was a lot more easier to work with in my opinion. For example, say you had two related tables; Product and ProductType - I could easily cross check the 'ProductTypeID' column of both tables for a particular row to quickly map the data in my head because its easy to store the number (2,4,45 etc) as opposed to (E75B92A3-3299-4407-A913-C5CA196B3CAB). The extra frustration comes from me wanting to

ASP.NET Core - custom AspNetCore.Identity implementation not working

匿名 (未验证) 提交于 2019-12-03 02:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm building a completely custom AspNetCore.Identity Implementation because I want TKey to be System.Guid across the board. With respect, I have derived types for... Role : IdentityRole<Guid, UserRole, RoleClaim> RoleClaim : IdentityRoleClaim<Guid> User : IdentityUser<Guid, UserClaim, UserRole, UserLogin> UserClaim : IdentityUserClaim<Guid> UserLogin : IdentityUserLogin<Guid> UserRole : IdentityUserRole<Guid> UserToken : IdentityUserToken<Guid> ApplicationDbContext : IdentityDbContext<User, Role, Guid, UserClaim, UserRole, UserLogin,

.Net Core3.0依赖注入DI

徘徊边缘 提交于 2019-12-03 02:19:33
原文: .Net Core3.0依赖注入DI 构建ASP.NET Core应用程序的时候,依赖注入已成为了.NET Core的核心,这篇文章,我们理一理依赖注入的使用方法。 不使用依赖注入 首先,我们创建一个ASP.NET Core Mvc项目,定义个表达的爱服务接口,中国小伙类实现这个类如下: public interface ISayLoveService { string SayLove(); } public class CNBoyService : ISayLoveService { public string SayLove() { return "安红,我喜欢你"; } } 在LoveController 控制器中调用 ISayLoveService的SayLove方法。 public class LoveController : Controller { private ISayLoveService loveService; public IActionResult Index() { loveService = new CNBoyService(); //中国小伙对安红的表达 ViewData["SayLove"] = loveService.SayLove(); return View(); } } 输出如图: 小结

TemporaryGeneratedFile_[guid] in /obj/debug breaking build

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have 3 temporary files being created in obj/debug: E.g. TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs (The guids don't seem to change even after a solution clean) My build is failing because: SA1633: The file has no header, the header Xml is invalid, or the header is not located at the top of the file. I don't want to turn the StyleCop rule off. How do I find out what is creating these

Extract thumbnail for any file in Windows

匿名 (未验证) 提交于 2019-12-03 02:13:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: What's the most efficient way of extracting thumbnails from any file, not just just images at varying sizes? I've looked all over, most promising of which was Windows API ShellFile yet this didn't appear to install properly. I'm using windows 7. 回答1: Some time ago I wrote a ThumbnailProvider that loads a thumbnail from the Win API. Supports transparent images. This is the implementation: using System; using System.Drawing; using System.Drawing.Imaging; using System.Runtime.InteropServices; using System.IO; namespace ThumbnailGenerator {

Introducing FOREIGN KEY constraint may cause cycles or multiple cascade paths

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am getting this error Introducing FOREIGN KEY constraint 'FK_dbo.Regions_dbo.Countries_CountryId' on table 'Regions' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints. Could not create constraint. See previous errors. I am wondering does this mean my database design is bad? I read you turn off the cascades or something like that but I am just not sure if that is sweeping the problem out of the rug. I am just letting EF generate my tables through my domain

Entity Framework 6 GUID as primary key: Cannot insert the value NULL into column &#039;Id&#039;, table &#039;FileStore&#039;; column does not allow nulls

匿名 (未验证) 提交于 2019-12-03 02:11:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have an entity with primary key "Id" which is Guid: public class FileStore { public Guid Id { get; set; } public string Name { get; set; } public string Path { get; set; } } And some configuration: protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity<FileStore>().Property(x => x.Id).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); base.OnModelCreating(modelBuilder); } When I try to insert a record I get a following error: Cannot insert the value NULL into column 'Id', table 'FileStore';

Why isn&#039;t there a Guid.IsNullOrEmpty() method

匿名 (未验证) 提交于 2019-12-03 02:06:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: This keeps me wondering why Guid in .NET does not have IsNullOrEmpty() method (where empty means all zeros) I need this at several places in my ASP.NET MVC code when writing the REST API. Or am I missing something because nobody on the Internet has asked for the same? 回答1: Guid is a value type , so a variable of type Guid can't be null to start with. If you want to know if it's the same as the empty guid, you can just use: if (guid == Guid.Empty) 回答2: For one thing, Guid is not nullable. You could check: myGuid == default(Guid) which is

Generating a unique ID in PHP

核能气质少年 提交于 2019-12-03 01:59:15
I'm trying to generate a unique ID in php in order to store user-uploaded content on a FS without conflicts. I'm using php, and at the moment this little snippet is responsible for generating the UID: $id = tempnam (".", ""); unlink($id); $id = substr($id, 2); This code is hideous: it creates a temporary file on the FS and deletes it, retaining only the relevant unique part of the generated string. Is there any better way to do this, most preferably without any external dependencies? Thanks much! string uniqid ([ string $prefix [, bool $more_entropy ]] ) Gets a prefixed unique identifier based

How to generate a GUID in Oracle?

匿名 (未验证) 提交于 2019-12-03 01:58:03
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it possible to auto-generate a GUID into an Insert statement? Also, what type of field should I use to store this GUID? 回答1: You can use the SYS_GUID() function to generate a GUID in your insert statement: insert into mytable (guid_col, data) values (sys_guid(), 'xxx'); The preferred datatype for storing GUIDs is RAW(16). As Gopinath answer: select sys_guid() from dual union all select sys_guid() from dual union all select sys_guid() from dual You get 88FDC68C75DDF955E040449808B55601 88FDC68C75DEF955E040449808B55601