public long?AddApartament(ViewAddress v, Guid userId) { Trace.Assert(_db != null); Trace.Assert(v != null); ObjectResult <long?> result = _db.AddApartament(v.Apartament, v.BuildingID, userId); Trace.Assert(result != null); IEnumerator <long?> resultList = result.GetEnumerator(); Trace.Assert(resultList != null); resultList.MoveNext(); long?id = resultList.Current; resultList.Dispose(); // for transaction to be able to complete return(id); }