コード例 #1
0
        public void AddUnit(Unit unit)
        {
            if (unit.Technology != null)
            {
                var persistedTechnology = _session.Get<Technology>(unit.Technology.TechnologyId);
                if (persistedTechnology == null)
                {
                    throw new ChildObjectNotFoundException("Technology not found");
                }
                unit.Technology = persistedTechnology;
            }

            // Persist unit and its relationships
            _session.SaveOrUpdate(unit);
        }
コード例 #2
0
        public virtual void UpdateUnitTechnology(Unit unit, long? technologyId)
        {
            unit.Technology = null;

            if (technologyId != null)
            {
                var technology = GetValidTechnology(technologyId.Value);
                unit.Technology = technology;
            }
        }