<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Blinq Preview</title><link>http://forums.asp.net/1076.aspx</link><description>Blinq is a tool for generating ASP.NET websites for displaying, creating, and manipulating data based on database schema.  You can provide feedback and ask questions about the Blinq preview in this forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/2339725.aspx</link><pubDate>Tue, 06 May 2008 07:50:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2339725</guid><dc:creator>Mathew.OPI</dc:creator><author>Mathew.OPI</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2339725.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=2339725</wfw:commentRss><description>&lt;p&gt;do u mean to get the last inserted value if the&amp;nbsp; identity&amp;nbsp;using DLINQ ?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;then it will the value once you execute the submitchange method&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1970547.aspx</link><pubDate>Wed, 24 Oct 2007 06:06:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1970547</guid><dc:creator>md_yahya</dc:creator><author>md_yahya</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1970547.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1970547</wfw:commentRss><description>&lt;p&gt;A Simple Way to get the ID. With Example&lt;/p&gt;
&lt;p&gt;dim authorid as string = &amp;quot;&amp;quot;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sql = &amp;quot;Insert into author(name,title) values(&amp;#39;yahya&amp;#39;,&amp;#39;ASP.NET&amp;#39;)&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sqlcommand.comandtext = sql&lt;br /&gt;SqlCOmmand.Connection = SqlCOnnection&amp;nbsp; &amp;#39; Define&amp;nbsp;your &amp;nbsp;sql connection&lt;br /&gt;Sqlcommand.connection.open()&lt;br /&gt;SqlCommand.ExecuteNonQuery()&lt;/p&gt;
&lt;p&gt;SqlCommand.Commandtext = &amp;quot;Select @@IDENTITY as authorid&amp;quot;&amp;nbsp;&amp;nbsp; &amp;#39; Your authorid should be an identity column .&lt;br /&gt;Dim dreader as Data.SqlCLient.SqlDatareader&lt;/p&gt;
&lt;p&gt;dreader = SqlCOmman.ExecuteReader(CommandBehaviour.closeconnection)&lt;br /&gt;if dreader.HasRows then&lt;br /&gt;&amp;nbsp;dreader.Read()&lt;br /&gt;authorid = dreader.item(&amp;quot;authorid&amp;quot;)&lt;br /&gt;End if&lt;/p&gt;
&lt;p&gt;Now You can return the autorid to any methods or Function as you like. Hope this will solve your problem.&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1403950.aspx</link><pubDate>Tue, 19 Sep 2006 16:44:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1403950</guid><dc:creator>micjones</dc:creator><author>micjones</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1403950.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1403950</wfw:commentRss><description>Are you interested in another approach?&amp;nbsp; I use SQL Server&amp;#39;s &amp;quot;inserted&amp;quot; and &amp;quot;deleted&amp;quot; temporary tables within a trigger to get the identity of the row just inserted/deleted.&amp;nbsp; If interested, I&amp;#39;ll further explain this technique.&amp;nbsp; BTW, I use Visio to design and create my databases.&amp;nbsp; Within that design context, Visio creates triggers used for maintaining integrity on updates, inserts, and deletes.</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1363646.aspx</link><pubDate>Mon, 07 Aug 2006 21:35:00 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1363646</guid><dc:creator>Dinesh.Kulkarni</dc:creator><author>Dinesh.Kulkarni</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1363646.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1363646</wfw:commentRss><description>&lt;p&gt;Based on a quick look, this seems about right. DLinq should take care of flowing the autogen id to related objects if they are mapped correctly (Blinq will do this if you have a foreign key relationship).&lt;/p&gt;
&lt;p&gt;Thanks.&lt;br /&gt;Dinesh&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1363021.aspx</link><pubDate>Mon, 07 Aug 2006 12:04:07 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1363021</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1363021.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1363021</wfw:commentRss><description>&lt;p&gt;Ok, Ok Its finally clicked for me...being an old sql developer getting my head round things like this gets confusing so to take this confusion away I've put together an example below which will hopefully help out others who were also confused...I hope I wasn't the only one...&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;using&lt;/font&gt;&lt;font size=2&gt; TestDb;&lt;/font&gt;&lt;/p&gt;&lt;font color=#0000ff size=2&gt;
&lt;p&gt;namespace&lt;/p&gt;&lt;/font&gt;&lt;font size=2&gt; LINQConsoleApplication1
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;class&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#008080 size=2&gt;Program&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;static&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;void&lt;/font&gt;&lt;font size=2&gt; Main(&lt;/font&gt;&lt;font color=#0000ff size=2&gt;string&lt;/font&gt;&lt;font size=2&gt;[] args)
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// Insert example ********************** &lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// create the database connection&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;Test&lt;/font&gt;&lt;font size=2&gt; db = &lt;/font&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#008080 size=2&gt;Test&lt;/font&gt;&lt;font size=2&gt;(&lt;/font&gt;&lt;font color=#800000 size=2&gt;"Data Source=********;Initial Catalog=Test;User ID=PaulWroe; password=******"&lt;/font&gt;&lt;font size=2&gt;);
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// Create a new class (as in class of pupils at a school, Maths, English etc)&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;Class&lt;/font&gt;&lt;font size=2&gt; englishClass = &lt;/font&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#008080 size=2&gt;Class&lt;/font&gt;&lt;font size=2&gt;();
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// set the name of the class&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;englishClass.ClassName = &lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"English"&lt;/font&gt;&lt;font size=2&gt;; 
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// create a child&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;Child&lt;/font&gt;&lt;font size=2&gt; student = &lt;/font&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#008080 size=2&gt;Child&lt;/font&gt;&lt;font size=2&gt;(); 
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// set the name of the child&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;student.ChildName = &lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"James Bankcroft"&lt;/font&gt;&lt;font size=2&gt;; 
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// add the child to the english class we just made, should be children &lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// not childs for readability, but this can be changed manually after pluralise has been used&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;englishClass.Childs.Add(student); &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// add the english class to the database (with the child (James) in the class)&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;db.Classes.Add(englishClass); &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// commit changes to the database and class is added to class table, &lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// child is added to the child table and the id's and relationship is &lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// maintained hence no need to use SCOPE_IDENTITY or @@IDENTITY manually!&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;db.SubmitChanges();&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// Update example ********************** &lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// Create a new class for maths&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;Class&lt;/font&gt;&lt;font size=2&gt; mathsClass = &lt;/font&gt;&lt;font color=#0000ff size=2&gt;new&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#008080 size=2&gt;Class&lt;/font&gt;&lt;font size=2&gt;();
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// change the classname property&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;mathsClass.ClassName = &lt;/p&gt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;"Maths"&lt;/font&gt;&lt;font size=2&gt;;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// get james back from the childs table&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;var&lt;/font&gt;&lt;font size=2&gt; some_child =
&lt;p&gt;(&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;from&lt;/font&gt;&lt;font size=2&gt; c &lt;/font&gt;&lt;font color=#0000ff size=2&gt;in&lt;/font&gt;&lt;font size=2&gt; db.Childs
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;where&lt;/font&gt;&lt;font size=2&gt; c.ChildName == &lt;/font&gt;&lt;font color=#800000 size=2&gt;"James Bankcroft"&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;select&lt;/font&gt;&lt;font size=2&gt; c
&lt;p&gt;).Single&amp;lt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008080 size=2&gt;Child&lt;/font&gt;&lt;font size=2&gt;&amp;gt;(); 
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// and move james from the english class to the newly created maths class&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;mathsClass.Childs.Add(some_child);&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#008000 size=2&gt;// commit changes&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;db.SubmitChanges();&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362895.aspx</link><pubDate>Mon, 07 Aug 2006 08:44:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362895</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362895.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362895</wfw:commentRss><description>&lt;p&gt;Sorry to keep barking on about this, but I have a project I need to finish and really need to crack this problem!&lt;/p&gt;
&lt;p&gt;Many thanks&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362602.aspx</link><pubDate>Sun, 06 Aug 2006 22:49:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362602</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362602.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362602</wfw:commentRss><description>&lt;p&gt;Thanks Dinesh and Polita for getting back to and helping me out. I'm still finding things a little unclear in regards to this line. I quote&lt;/p&gt;
&lt;p&gt;" If you are inserting a single object, then the id of that object is patched up using @@identity/scope_identity. So if you are looking for the id of the inserted object, that is available."&lt;/p&gt;
&lt;p&gt;Here is a simplified&amp;nbsp;idea for what I'm trying to achieve...&lt;/p&gt;
&lt;p&gt;I have an object called 'Nomination' each 'Nomination' object can have a number of file objects&amp;nbsp;attached to it, so it&amp;nbsp;has a collection of 'File' objects.&lt;/p&gt;
&lt;p&gt;Nomination object has NominatedBy, NominationId, and a collection of File objects.&lt;/p&gt;
&lt;p&gt;File object has Filename, and NominationId. &lt;/p&gt;
&lt;p&gt;The relationship is one to many.&lt;/p&gt;
&lt;p&gt;Nomination n = new Nomination();&lt;/p&gt;
&lt;p&gt;n.NominatedBy = "Paul Wroe";&lt;/p&gt;
&lt;p&gt;Nomination.Insert(n);&lt;/p&gt;
&lt;p&gt;File f = new File();&lt;/p&gt;
&lt;p&gt;f.NominationId = // here is where I need to tell the file object the Id of the just inserted Nomination&lt;/p&gt;
&lt;p&gt;Hope this explains things a little clearer and you can suggest a way to achieve this? or point me towards some documentation. &lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Paul Wroe&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362599.aspx</link><pubDate>Sun, 06 Aug 2006 22:31:43 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362599</guid><dc:creator>Dinesh.Kulkarni</dc:creator><author>Dinesh.Kulkarni</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362599.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362599</wfw:commentRss><description>&lt;p&gt;Sorry, there is no non-SQL way to get the last auto-generated identity in the db. Typically, Blinq/DLinq can handle multiple inserts in a concurrent environment and hence within the scope of a DataContext, the last id is really not applicable. Hence we have not added an API. If you are inserting a single object, then the id of that object is patched up using @@identity/scope_identity. So if you are looking for the id of the inserted object, that is available. If you are looking for the last, database-wide id, you will need to use the SQL command (directly or via DataContext pass through - ExecuteQuery() ).&lt;/p&gt;
&lt;p&gt;I am curious to understand your scenario for our future API design.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Dinesh&lt;br /&gt;(Program Manager - DLinq)&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362530.aspx</link><pubDate>Sun, 06 Aug 2006 19:41:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362530</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362530.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362530</wfw:commentRss><description>&lt;p&gt;Yes, its an identity column, when a record is inserted the identity is auto generated by the db, this is the value i wish to return after the insert,&lt;/p&gt;
&lt;p&gt;many thanks!&lt;/p&gt;</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362491.aspx</link><pubDate>Sun, 06 Aug 2006 18:53:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362491</guid><dc:creator>phuff</dc:creator><author>phuff</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362491.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362491</wfw:commentRss><description>Redtap, is this a record whose primary key is auto-id'd on insert?</description></item><item><title>Re: Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1362481.aspx</link><pubDate>Sun, 06 Aug 2006 18:34:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1362481</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1362481.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1362481</wfw:commentRss><description>Please help! I will resolve to begging!!!</description></item><item><title>Getting the Identity of the last Inserted row!</title><link>http://forums.asp.net/thread/1360991.aspx</link><pubDate>Fri, 04 Aug 2006 10:16:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1360991</guid><dc:creator>redtap</dc:creator><author>redtap</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1360991.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=1076&amp;PostID=1360991</wfw:commentRss><description>&lt;p&gt;Can anyone tell me how to get the identity of the last inserted row? I'm using DLINQ so please don't tell me how to do this in SQL as I know this. In SQL I would use SCOPE_IDENTITY() or @@IDENTITY (generally not the latter)&lt;/p&gt;
&lt;p&gt;Please help! I have project to be finished ASAP and this is the only bit holding me back!&lt;/p&gt;
&lt;p&gt;Thanks !&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>