public long?AddDevice(ViewDevice v, Guid userId) { Trace.Assert(_db != null); ObjectResult <long?> result = _db.AddDevice(v.Name, v.InternalAddress, v.AddressType, v.Port, v.GroupID, v.TypeID, v.OwnerID, v.IP1, v.IP2, v.IP3, v.IP4, v.SecondaryPort, v.SecondaryIP1, v.SecondaryIP2, v.SecondaryIP3, v.SecondaryIP4, userId, null, false); Trace.Assert(result != null); IEnumerator <long?> resultList = result.GetEnumerator(); Trace.Assert(resultList != null); resultList.MoveNext(); long?deviceId = resultList.Current; resultList.Dispose(); // for transaction to be able to complete return(deviceId); }