示例#1
0
        /// <summary>
        /// Returns the EntityGroup associated with a specific Entity subtype.
        /// </summary>
        /// <param name="clrEntityType">An <see cref="IEntity"/> subtype</param>
        /// <returns>The <see cref="EntityGroup"/> associated with the specified Entity subtype</returns>
        /// <exception cref="ArgumentException">Bad entity type</exception>
        /// <exception cref="EntityServerException"/>
        internal EntityGroup GetEntityGroup(Type clrEntityType)
        {
            var eg = this.EntityGroups[clrEntityType];

            if (eg != null)
            {
                return(eg);
            }

            lock (this.EntityGroups) {
                // check again just in case another thread got in.
                eg = this.EntityGroups[clrEntityType];
                if (eg != null)
                {
                    return(eg);
                }

                eg = EntityGroup.Create(clrEntityType, this);
                this.EntityGroups.Add(eg);
                // ensure that any entities placed into the table on initialization are
                // marked so as not to be saved again
                eg.AcceptChanges();

                return(eg);
            }
        }
示例#2
0
 private void AddEntityGroup(EntityGroup entityGroup)
 {
     // don't both checking if an entityGroup with the same key already exists
     // should have been checked in calling code ( and will fail in the Add if not)
     entityGroup.EntityManager = this;
     entityGroup.EntityType    = this.MetadataStore.GetEntityType(entityGroup.ClrType);
     // insure that any added table can watch for change events
     entityGroup.ChangeNotificationEnabled = true;
     this.EntityGroups.Add(entityGroup);
 }