High-Performance Development - C#, VB, SQL, ASP.NET

Slogan Text

Linq puts the identity (Id) of the inserted record into the inserted instance object during the Submit operation. After calling Submit get the Id. 

Example:

        public void HandleInsert(string Handle, int CompanyId, ref long HandleId)
        {
            DataClasses1DataContext DbObj;
            PhraseHandle HandleObj;

            using (DbObj = new DataClasses1DataContext())
            {
                HandleObj = new PhraseHandle();
                HandleObj.PhraseHandle1 = Handle;
                HandleObj.CompanyId = CompanyId;
                DbObj.PhraseHandles.InsertOnSubmit(HandleObj);
                DbObj.SubmitChanges();
                HandleId = HandleObj.PhraseHandleId;
            }
        }