guid

Guid == null should not be allowed by the compiler

匿名 (未验证) 提交于 2019-12-03 01:56:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: C# okay with comparing value types to null The behaviour described below is specific to .net-3.5 only Hello, 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

The parameterized query … expects the parameter '@units', which was not supplied

匿名 (未验证) 提交于 2019-12-03 01:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm getting this exception: The parameterized query '(@Name nvarchar(8),@type nvarchar(8),@units nvarchar(4000),@rang' expects the parameter '@units', which was not supplied. My code for inserting is: public int insertType(string name, string type, string units = "N\\A", string range = "N\\A", string scale = "N\\A", string description = "N\\A", Guid guid = new Guid()) { using (SqlConnection connection = new SqlConnection(connectionString)) { connection.Open(); SqlCommand command = new SqlCommand(); command.CommandText = "INSERT INTO Type

Can you use auto-increment in MySql with out it being the primary Key

匿名 (未验证) 提交于 2019-12-03 01:48:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using GUIDs as my primary key for all my other tables, but I have a requirement that needs to have an incrementing number. I tried to create a field in the table with the auto increment but MySql complained that it needed to be the primary key. My application uses MySql 5, nhibernate as the ORM. Possible solutions I have thought of are: change the primary key to the auto-increment field but still have the Id as a GUID so the rest of my app is consistent. create a composite key with both the GUID and the auto-increment field. My thoughts

.Net Core3.0依赖注入DI

为君一笑 提交于 2019-12-03 01:33:41
构建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(); } } 输出如图: 小结

c++ “no matching function for call to” error with structure

匿名 (未验证) 提交于 2019-12-03 01:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have C++ code that maps GUID(unsigned long) to structure. #include #include #include typedef unsigned long GUID; enum Function { ADDER = 1, SUBTRACTOR = 2, MULTIPLIER = 3, SQUAREROOT = 4 }; struct PluginInfo { GUID guid; std::string name; Function function; PluginInfo(GUID _guid, std::string _name, Function _function) {guid = _guid, name = _name, function = _function;} }; typedef std::map PluginDB; PluginInfo temp1(1, "Adder", ADDER); PluginInfo temp2(2, "Multiplier", MULTIPLIER); PluginDB::value_type pluginDbArray[] = { PluginDB::value

generate guid for every row in a column

匿名 (未验证) 提交于 2019-12-03 01:23:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I Have a stored procedure that has a table with one column and I need to generate a NEWID() for each row in that column. Would I only be able to accomplish this with a loop? +---+ +--------------------------------------+---+ | a | | FD16A8B5 - DBE6 - 46AB - A59A - 6B6674E9A78D | a | | b | => | 9E4A6EE6 - 1C95 - 4C7F - A666 - F88B32D24B59 | b | | c | | 468C0B23 - 5A7E-404E - A9CB - F624BDA476DA | c | +---+ +--------------------------------------+---+ 回答1: You should be able to select from your table and include the newid() to

Use function as default value for column in Oracle11g

匿名 (未验证) 提交于 2019-12-03 01:20:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We are testing out Oracle at my work and im in charge of building all of the database objects (tables, procs, trigger, etc) on Oracle, and we currently use Microsoft SQL Server 2008 R2. We use uniqueidentifier's for almost all of our ID column's. I used this function to create GUID's: CREATE OR REPLACE FUNCTION NEWID RETURN CHAR IS guid CHAR(36) ; BEGIN SELECT SYS_GUID() INTO guid FROM DUAL; guid := SUBSTR(guid, 1, 8) || '-' || SUBSTR(guid, 9, 4) || '-' || SUBSTR(guid, 13, 4) || '-' || SUBSTR(guid, 17, 4) || '-' || SUBSTR(guid, 21); RETURN

A typescript Guid class?

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Does anyone know of a good, solid, implementation of C# like Guid in typescript? Could do it myself but figured I'd spare my time if someone else done it before. Thanks! 回答1: There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: class Guid { static newGuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8); return v.toString(16); }); } } // Example of a bunch of GUIDs for (var i = 0; i Please note

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) in VS Extensibility walkthrough

匿名 (未验证) 提交于 2019-12-03 01:18:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using the Walkthrough: Part 1 - Creating a Basic Project System exactly as written from the website http://msdn.microsoft.com/en-us/library/cc512961.aspx and the Managed Package Framework for Projects exactly as downloaded from http://mpfproj11.codeplex.com/ . I have tested the walkthrough on multiple development machines in Visual Studio 2013. I also tested this in Visual Studio 2010 and 2012 using their respective SDK’s. The same issues to follow presented themselves in each of the tests. Issue: I am receiving the exception- An

Convert .NET Guid to MongoDB ObjectID

半腔热情 提交于 2019-12-03 01:14:59
How can I convert a .NET GUID to a MongoDB ObjectID (in C#). Also, can I convert it back again to the same GUID from the ObjectID? Andrew Orsich You can't convert ObjectId into GUID and vice versa, because they are two different things(different sizes, algoritms). You can use any type for mongoDb _id including GUID . For example in official c# driver you should specify attribute [BsonId] : [BsonId] public Guid Id {get;set;} [BsonId] public int Id {get;set;} ObjectId : A BSON ObjectID is a 12-byte value consisting of a 4-byte timestamp (seconds since epoch), a 3-byte machine id, a 2-byte