<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : First time trying to use Generate Id</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2010 : First time trying to use Generate Id</description>
  <pubDate>Tue, 21 Apr 2026 22:30:35 -700</pubDate>
  <lastBuildDate>Thu, 05 Aug 2010 13:25:56 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=2039</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>First time trying to use Generate Id : Glad you got it working! Thanks...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=8006#8006</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 05-Aug-2010 at 1:25pm<br /><br /><P>Glad you got it working!&nbsp; Thanks for letting us know.</P><DIV></DIV>]]>
   </description>
   <pubDate>Thu, 05 Aug 2010 13:25:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=8006#8006</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : I finally got it to work. I made...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7985#7985</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 04-Aug-2010 at 3:26pm<br /><br />I finally got it to work. I made two mistakes. I didn't change the namespace in the NumericGenerator and I didn't change the datasourcekey(). I did have to change the code to look for a field called nextid1 because the designer would not allow me to have a fieldname with the same name as the table.<br><br><br>]]>
   </description>
   <pubDate>Wed, 04 Aug 2010 15:26:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7985#7985</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : So afew comments:   1) When...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7984#7984</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 04-Aug-2010 at 3:09pm<br /><br />So a&nbsp;few comments: <DIV>&nbsp;</DIV><DIV>1)&nbsp; When you are using invoiceno as the primary key, are you using our NumericIdGenerator or did you implement your own IIDGenerator?&nbsp; (Or if you have none, that might also explain the null insert exception.)</DIV><DIV>&nbsp;</DIV><DIV>2)&nbsp; If you use Identity columns for the primary keys, you don't need to implement an IIdGenerator or call EntityManager.GenerateId().</DIV><DIV>&nbsp;</DIV><DIV>3)&nbsp; For the SalesInvoice table, it may be simpler to declare the invoiceno as an Identity column, but if this invoiceno is visible to the end user, you will buy some future flexibility by having a separate column as the primary key.&nbsp; It's a little more work though as you still have to create a unique invoiceno for each SalesInvoice.</DIV><DIV>&nbsp;</DIV><DIV>If you want to keep things simple, just declare everything as an Identity column and then you don't have to worry about any ID Generation.&nbsp; Using GUIDs as primary keys&nbsp;is also&nbsp;simple and has the advantage that the entities&nbsp;don't have to use a temporary ID before being assigned one from the server.&nbsp; Their disadvantage is of course that they are long and hard to read.</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Wed, 04 Aug 2010 15:09:17 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7984#7984</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : Are you suggesting this?  SalesInvoice...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7971#7971</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 03-Aug-2010 at 5:28pm<br /><br />Are you suggesting this?<DIV>&nbsp;</DIV><DIV>SalesInvoice table</DIV><DIV>&nbsp;</DIV><DIV>Id int identity</DIV><DIV>int invoiceno&nbsp;&nbsp; generated by nextinvioceno from a lookup table</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>SalesInvoiceLine table</DIV><DIV>id in identity</DIV><DIV>int invoiceno</DIV><DIV>int lineno</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV>]]>
   </description>
   <pubDate>Tue, 03 Aug 2010 17:28:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7971#7971</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : This is actually the error I am...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7970#7970</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 03-Aug-2010 at 5:26pm<br /><br />This is actually the error I am getting <DIV>&nbsp;</DIV><DIV>Cannot insert the value NULL into column 'InvoiceNo', table 'SEIU99.dbo.SalesInvoices'; column does not allow nulls. INSERT fails.<BR>The statement has been terminated.</DIV><DIV>&nbsp;</DIV><DIV>&nbsp;</DIV><DIV>Salesinvoices is the parent table. Right before it goes into the SaveChanges method SalesInvoice.InvoiceNo = -100</DIV><DIV>and the lone detail record is -100,1</DIV>]]>
   </description>
   <pubDate>Tue, 03 Aug 2010 17:26:25 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7970#7970</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : Can you confirm that each SalesInvoiceLine...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7969#7969</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=477" rel="nofollow">ting</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 03-Aug-2010 at 5:08pm<br /><br /><P>Can you confirm that each SalesInvoiceLine is pointing to the correct SalesInvoice?</P><P>What is the "invoices" property on SalesInvoice that the exception is complaining should not be null?</P><P>Also, if you have flexibility on the schema, consider creating a dedicated primary key with no semantic information on your tables instead of using a compound key.&nbsp; Performance will be better, and if the application grows, it supports a larger variety of scenarios.<BR></P>]]>
   </description>
   <pubDate>Tue, 03 Aug 2010 17:08:56 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7969#7969</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : Any ideas?  </title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7959#7959</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 03-Aug-2010 at 9:53am<br /><br />Any ideas?<DIV></DIV>]]>
   </description>
   <pubDate>Tue, 03 Aug 2010 09:53:21 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7959#7959</guid>
  </item> 
  <item>
   <title>First time trying to use Generate Id : I have two tables in my database...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7945#7945</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=202" rel="nofollow">BillG</a><br /><strong>Subject:</strong> 2039<br /><strong>Posted:</strong> 01-Aug-2010 at 2:04pm<br /><br />I have two tables in my database SalesInvoices and SalesInvoiceLines. The SalesInvoices table has a pk of invoiceNo<DIV>and the SalesInvoicesLine table has a pk of InvoiceNo and LineNo. The SalesInvoiceLines table has a FK to invoiceno of SalesInvoice. I have a table named NextId with a field called Global and it has a value of 100 in it.</DIV><DIV>&nbsp;</DIV><DIV>Here is my SalesInvoice.Create</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>public</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>static</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>SalesInvoice</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> Create(IbEm.</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>EntityManager</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> mgr)</P><P>{</P><P></FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>SalesInvoice</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> aSalesInvoice = mgr.CreateEntity&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>SalesInvoice</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;();</P><P>aSalesInvoice.InvoiceDate = </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>DateTime</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.Now;</P><P>aSalesInvoice.InvoiceTotal = 0;</P><P>aSalesInvoice.AmountPaid = 0;</P><P>mgr.GenerateId(aSalesInvoice, </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>SalesInvoice</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>PropertyMetadata</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>.InvoiceNo);</P><P>aSalesInvoice.EntityAspect.AddToManager();</P><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>return</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> aSalesInvoice;</P><P>}</P><DIV>&nbsp;</DIV><DIV>Here is my save. I am saving the currentSalesInvoice which is an object of the SalesInvoice class and the detail lines which are a collection of the SalesInvoiceLines class.</DIV><DIV>&nbsp;</DIV><DIV><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>try</P></FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas><P>{</P><P></FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>List</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Entity</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt; changedEntities = </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>List</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&lt;</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Entity</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>&gt;();</P><P>changedEntities.Add(currentSalesInvoice);</P><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>foreach</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> (</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>SalesInvoiceLine</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> s </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>in</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> invoiceLines)</P><P>{</P><P>changedEntities.Add(s);</P><P>}</P><P>entityManager.SaveChanges(changedEntities);</P><P>invoiceLines = </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>null</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>;</P><P>}</P><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>catch</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(</FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Exception</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> ex)</P><P>{</P><P></FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>throw</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas><FONT color=#0000ff size=2 face=C&#111;nsolas>new</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas> </FONT></FONT><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas><FONT color=#2b91af size=2 face=C&#111;nsolas>Exception</FONT></FONT></FONT><FONT size=2 face=C&#111;nsolas><FONT size=2 face=C&#111;nsolas>(ex.Message);</P><P>}</P><DIV>when the save occurs I am getting a cannot insert into salesinvoices table with a null value for invoices.</DIV><DIV>&nbsp;</DIV><DIV></FONT></FONT></FONT></FONT>&nbsp;</DIV></DIV></DIV>]]>
   </description>
   <pubDate>Sun, 01 Aug 2010 14:04:02 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=2039&amp;PID=7945#7945</guid>
  </item> 
 </channel>
</rss>