Esempio n. 1
0
 private void UpdateElement(int max)
 {
     Parallel.For(0, max, i =>
     {
         using (var tx = store.BeginSession())
         {
             var a  = store.GetElement <XExtendsBaseClass>(ids[i]);
             a.Name = "Toto" + i;
             tx.AcceptChanges();
         }
     });
 }
        internal IModelElement GetReference(ref Identity relationshipId, ISchemaRelationship relationshipSchema, bool isOpposite)
        {
            DebugContract.Requires(relationshipSchema, "relationshipSchema");

            var propertyName = isOpposite ? relationshipSchema.EndPropertyName : relationshipSchema.StartPropertyName;

            SetCalculatedPropertySource(propertyName);

            IModelRelationship relationship = null;

            if (relationshipId != null)
            {
                relationship = DomainModel.GetRelationship(relationshipId);
            }

            if (relationship == null)
            {
                var start = isOpposite ? null : this;
                var end   = isOpposite ? this : null;
                relationship = DomainModel.GetRelationships(relationshipSchema, start, end).FirstOrDefault();
            }

            if (relationship != null)
            {
                relationshipId = relationship.Id;

                var opposite = isOpposite ? relationship.Start : relationship.End;
                if (opposite != null)
                {
                    var mel = _store.GetElement(opposite.Id);
                    if (mel == null)
                    {
                        throw new InvalidElementException(opposite.Id, ExceptionMessages.InvalidReference);
                    }

                    return(mel);
                }
                return(opposite);
            }

            relationshipId = null;
            return(null);
        }