identity

Types for which “is” keyword may be equivalent to equality operator in Python

与世无争的帅哥 提交于 2019-12-18 06:58:12
问题 For some types in Python, the is operator seems to be equivalent to the == operator. For example: >>> 1 is 1 True >>> "a spoon" is "a spoon" True >>> (1 == 1) is (2 == 2) True However, this is not always the case: >>> [] == [] True >>> [] is [] False This makes sense for mutable types such as lists. However, immutable types such as tuples seem to display the same behavior: >>> (1, 2) == (1, 2) True >>> (1, 2) is (1, 2) False This raises several questions: Is the == / is equivalence related to

How do you find the users name/Identity in C#

自古美人都是妖i 提交于 2019-12-18 05:37:56
问题 I need to programatically find the users name using C#. Specifically, I want to get the system/network user attached to the current process. I'm writing a web application that uses windows integrated security. 回答1: The abstracted view of identity is often the IPrincipal / IIdentity : IPrincipal principal = Thread.CurrentPrincipal; IIdentity identity = principal == null ? null : principal.Identity; string name = identity == null ? "" : identity.Name; This allows the same code to work in many

In SQL Server, should I create an index for an identity column, or is it created automatically?

吃可爱长大的小学妹 提交于 2019-12-18 04:33:08
问题 I believe when I create an identity column it gets indexed automatically, but I'm not 100% sure. Should I create an index for an identity column, or is it created automatically? 回答1: create table test (Id int identity) go sp_help test The object 'test' does not have any indexes, or you do not have permissions. No constraints are defined on object 'test', or you do not have permissions. As a general practice you would create a unique index on your identity column, this speeds up lookups.

Python identity: Multiple personality disorder, need code shrink [duplicate]

寵の児 提交于 2019-12-18 04:09:09
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Python “is” operator behaves unexpectedly with integers I stumbled upon the following Python weirdity: >>> two = 2 >>> ii = 2 >>> id(two) == id(ii) True >>> [id(i) for i in [42,42,42,42]] [10084276, 10084276, 10084276, 10084276] >>> help(id) Help on built-in function id in module __builtin__: id(...) id(object) -> integer Return the identity of an object. This is guaranteed to be unique among simultaneously

How to automatically reseed after using identity_insert?

白昼怎懂夜的黑 提交于 2019-12-18 03:55:01
问题 I recently migrated from a PostgreSQL database to a SQL Server database. To switch the data over I had to enable IDENTITY_INSERT. Well come to find out that I get all sorts of strange errors due to duplicate identity values(which are set as primary keys) upon doing an insert in any of the tables. I have quite a few tables. What would be the easiest way of automatically reseeding the identity of every table so that it is after max(RID) ? 回答1: Use the information in this link in combination

How do I MANUALLY set an Identity field in LINQ-To-SQL (IDENTITY INSERT)

丶灬走出姿态 提交于 2019-12-18 03:37:05
问题 I have a table that normally, upon insert, the auto-key will increment. But, there are some instances when we want to set the ID (as would easily be done with "IDENTITY INSERT" in SQL). Is there a way to accomplish this with LINQ to SQL? Thanks, 回答1: Take a look here: http://social.msdn.microsoft.com/Forums/en-US/linqtosql/thread/566e9540-911e-48b4-ac31-f69c0ab9f7fb/ Last reply here: http://forums.asp.net/t/1208607.aspx 回答2: If you want to make IDENTITY increment always OFF Edit the Model

Chrome identity launchWebAuthFlow only opens empty callback page

偶尔善良 提交于 2019-12-18 03:17:14
问题 Sorry for yet another probably noob question, normally I don't give in until I find a solution myself but this one has me going for 3 days and it is time to admit I'm stuck... I'm trying to authenicate a Chrome extension to use PushBullet user data via OAuth2: background.js var client_id = '<32 DIGIT CLIENT ID>'; var redirectUri = "chrome-extension://lgekckejcpodobwpelekldnhcbenimbe/oauth2"; var auth_url = "https://www.pushbullet.com/authorize?client_id=" + client_id + "&redirect_uri=" +

DDD, value objects and ORM

Deadly 提交于 2019-12-18 00:42:53
问题 Value objects do not have identity. ORM needs identity to update the database. How to trick ORM? (Marking Id for value object as internal won't work because ORM lives in a different assembly and moving it to the same assembly is not acceptable). Thanks in advance. 回答1: As far as my understanding of DDD goes value objects are just a way to partition your entities. If a value object should be stored with an ID in the database it's not a value object. Example: The domain model looks like this (C

R object identity

六月ゝ 毕业季﹏ 提交于 2019-12-17 19:36:28
问题 is there a way to test whether two objects are identical in the R language? For clarity: I do not mean identical in the sense of the identical function, which compares objects based on certain properties like numerical values or logical values etc. I am really interested in object identity, which for example could be tested using the is operator in the Python language. 回答1: UPDATE : A more robust and faster implementation of address(x) (not using .Internal(inspect(x)) ) was added to data

Index autoincrement for Microsoft SQL Server 2008 R2

五迷三道 提交于 2019-12-17 18:35:52
问题 I created a new table in SQL Server 2008 R2, and i would like that the index is on autoincrement. How to do that? There is no identity data type; i selected int 回答1: In SQL Server, it's not a separate datatype ("autoincrement") - but you can define an INT column to be an IDENTITY . How are you creating your table - visual designer or T-SQL script?? In T-SQL, you would use: CREATE TABLE dbo.MyTable(ID INT IDENTITY(1,1) ...... and in the visual table designer, you need to check: It's an option