private DeviceDataViewModel Copy(Guid pId) { var itemCopy = _deviceData.Clone() as DeviceData; if (itemCopy != null) { itemCopy.parentId = pId; itemCopy.DeviceInfo = DeviceContext.Instance.DeviceInfos.Find(pId); } DeviceContext.Instance.DeviceDatas.AddOrUpdate(itemCopy); DeviceContext.Instance.SaveChanges(); return(new DeviceDataViewModel(itemCopy)); }