identity

How to get Identity value from SQL server after insert record

纵饮孤独 提交于 2020-01-04 04:16:11
问题 I add a record in my database with an identity value. I want to get the identity value after inserting. I don't want to do that by stored procedure. This is my code: SQLString = " INSERT INTO myTable "; SQLString += " (Cal1, Cal2, Cal3, Cal4) "; SQLString += " VALUES(N'{0}',N'{1}',N'{2}',N'{3}') "; SQLString = string.Format(SQLString, Val1, Val2, Val3, Val4); SQLString += " Declare @_IdentityCode INT SET @_IdentityCode = @@IDENTITY RETURN @_IdentityCode"; int result; public int DoCommand2

Workaround for LINQ to SQL Entity Identity Caching and Compiled Query Bug?

↘锁芯ラ 提交于 2020-01-03 18:22:33
问题 I've come across what appears to be a bug in linq to sql where identity caching does not work when performing primary key queries inside of a compiled query. I wrote the following sample to demonstrate the usage of identity caching. It only executes one call to the database the first time it's hit, every time after that it retrieves the customer entity from the data context's cache. for(int i=0; i<10; i++) { DataContext.GetTable<Customer>().Single(c=>c.Id == 1); } Unfortunately, when I

Workaround for LINQ to SQL Entity Identity Caching and Compiled Query Bug?

孤者浪人 提交于 2020-01-03 18:21:55
问题 I've come across what appears to be a bug in linq to sql where identity caching does not work when performing primary key queries inside of a compiled query. I wrote the following sample to demonstrate the usage of identity caching. It only executes one call to the database the first time it's hit, every time after that it retrieves the customer entity from the data context's cache. for(int i=0; i<10; i++) { DataContext.GetTable<Customer>().Single(c=>c.Id == 1); } Unfortunately, when I

HtmlUnit and Fragment Identities

非 Y 不嫁゛ 提交于 2020-01-03 15:38:38
问题 I'm currently wondering how to deal with fragment identities, a link that I am wanting to grab information from, contains a fragment identity. It seems as if HtmlUnit is discarding the "#/db4mj" of my url and therefore loading the original url. Does anyone know of a way to deal with fragment identities? (I can post example code to further explain if need be) EDIT Since I wasn't getting many views (and no answers), I'm going to add a bounty. Sorry it's only 50, but I only had 79 to start with

全新的membership框架Asp.net Identity(2)——绕不过的Claims

て烟熏妆下的殇ゞ 提交于 2020-01-03 10:42:17
本来想直接就开始介绍Identity的部分,奈何自己挖坑太深,高举高打的方法不行。只能自己默默下载了Katana的源代码研究了好一段时间。发现要想能够理解好用好Identity, Claims是一个绕不过的内容。今天就和大家一起分享一下什么是Claims以及为什么Identity要基于Claims. 阅读目录: 一. 什么是Claims以及基于Claims的identity验证 二. 使用基于Claims的Identity验证的优势 三. Claims是如何应用在Asp.net中? 四,一些更深入的补充说明 一,什么是Claims以及基于Claims的identity验证 实际上,基于Claims的identity验证早已经被应用到我们生活中的很多方面。一个非常典型的例子就是我们到机场登机的过程。我们乘坐飞机,是不能够直接直接拿着机票和身份证就上飞机的,需要先到柜台上领登机牌. 到了指定柜台上,出示身份证和机票,办理物品托运,选好座位,确认后,才能换取登机牌。这个时候你才能凭借登机牌过安检和上飞机。 登机过程中,工作人员扫一下这个小小的登机牌,就能获取到很多信息: 比如,你已经是经过航空公司认证过的乘客,你的航班号,座位号,你的名字等。工作人员只要核对这些信息,就会允许你上对应的飞机和指定的座位。 以Claims的角度重新看待登机过程 OK. 我们再来捋一捋这个过程

web.config convert saml security token to claim principal

旧街凉风 提交于 2020-01-03 04:51:10
问题 I have problem to validate the security token, i tried to use your code and other too, but when it try to validate ST I have thi error: ID4175: The issuer of the security token was not recognized by the IssuerNameRegistry. To accept security tokens from this issuer, configure the IssuerNameRegistry to return a valid name for this issuer i don't know hot confire the web config, can you help me? this is the code: //Microsoft.IdentityModel.Configuration.ServiceConfiguration serviceConfig = new

How can I get inserted ID in SQL Server while using SqlClient class?

丶灬走出姿态 提交于 2020-01-02 07:05:30
问题 So this is a continuation of post: Best way to get identity of inserted row? That post proposes, and I agree, to use Inserted feature to safely return inserted id column(s). While implementing this feature, it seems SqlClient of the .net framework does not support this feature, and fails while trying to execute command, I get the following exception: System.Data.SqlClient.SqlException: 'Cannot find either column "INSERTED" or the user-defined function or aggregate "INSERTED.Id", or the name

How can I get inserted ID in SQL Server while using SqlClient class?

久未见 提交于 2020-01-02 07:05:13
问题 So this is a continuation of post: Best way to get identity of inserted row? That post proposes, and I agree, to use Inserted feature to safely return inserted id column(s). While implementing this feature, it seems SqlClient of the .net framework does not support this feature, and fails while trying to execute command, I get the following exception: System.Data.SqlClient.SqlException: 'Cannot find either column "INSERTED" or the user-defined function or aggregate "INSERTED.Id", or the name

Group by identity in Ruby

ぐ巨炮叔叔 提交于 2020-01-02 05:56:50
问题 How does Ruby's group_by() method group an array by the identity (or rather self ) of its elements? a = 'abccac'.chars # => ["a", "b", "c", "c", "a", "c"] a.group_by(&:???) # should produce... # { "a" => ["a", "a"], # "b" => ["b"], # "c" => ["c", "c", "c"] } 回答1: In a newer Ruby (2.2+?), a.group_by(&:itself) In an older one, you still need to do a.group_by { |x| x } 回答2: Perhaps, this will help: a = 'abccac'.chars a.group_by(&:to_s) #=> {"a"=>["a", "a"], "b"=>["b"], "c"=>["c", "c", "c"]}

How can I Identify unique users on my website even IP is changed or browser data has been cleared?

风格不统一 提交于 2020-01-02 03:31:46
问题 I am developing a video streaming website. I want to count unique views on each video. I referred to some sites on internet and even asked some other programmers. They say either use cookies or session or IP address. But these things changes over time. Also if possible can we do this using MAC address of the user's machine? Also I came across a similar question here -> http://bit.ly/Qh1KNR. They say there is something like browser fingerprint that uses MAC address. So can you tell me what