newRecord.Id

On Mon, Apr 26, 2010 at 7:23 PM, comicrage <[email protected]> wrote:
> Hi,
>
> I am learning LINQtoSQL and was successful in adding new records to
> tables using the following code
>
>                myDataContext db = new myDataContext ();
>
>                try
>                {
>                    db.Batches.InsertOnSubmit(newRecord);
>                    db.Batches.Context.SubmitChanges();
>                }
>                catch (ChangeConflictException ex)
>                {
>                    // resolve all conflicts
>
> db.ChangeConflicts.ResolveAll(RefreshMode.KeepChanges);
>                    Log.Write(SeverityLevel.Error, ex);
>                }
>
> I just realize that I need the return the primary key, recordID, for
> each new added record. When I used the intellisense, I see that
> InsertOnSubmit returns void.
>
> My question: How can I get the new record ID when I just inserted the
> new record?
>
> Thanks
>
>
> --
> Subscription settings: 
> http://groups.google.com/group/dotnetdevelopment/subscribe?hl=en
>

Reply via email to