Beispiel #1
0
        internal EntityIndex(EntityType entityType, IndexAttribute attr)
            : base(attr.Name, attr.NativeName)
        {
            this.Initialize(entityType);
            if (EntityType == null)
            {
                throw new InvalidOperationException("EntityType is null.");
            }

            // set...
            _hasUniqueValues = attr.HasUniqueValues;

            // setup the fields...
            if (attr.ColumnNativeNames == null)
            {
                throw new InvalidOperationException("'attr.ColumnNativeNames' is null.");
            }
            if (attr.ColumnNativeNames.Length == 0)
            {
                throw new InvalidOperationException("'attr.ColumnNativeNames' is zero-length.");
            }

            // add...
            AddColumns(entityType, attr.ColumnNativeNames, this.Fields);
            this.IncludedFields = new EntityFieldCollection(entityType);
            AddColumns(entityType, attr.IncludedColumns, this.IncludedFields);
            this.ComputedFields = new EntityFieldCollection(entityType);
            AddColumns(entityType, attr.ComputedColumns, this.ComputedFields);
        }
Beispiel #2
0
        private void Initialize(EntityType entityType)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }
            this.SetEntityType(entityType);

            // create...
            _fields = new EntityFieldCollection(this.EntityType);
        }
Beispiel #3
0
        private void AddColumns(EntityType et, string names, EntityFieldCollection fields)
        {
            if (names == null)
            {
                return;
            }

            //  walk...
            string[] parts = names.Split(',');
            foreach (string name in parts)
            {
                string useName = name.Trim();

                // find...
                EntityField field = et.Fields.GetField(useName, OnNotFound.ThrowException);
                if (field == null)
                {
                    throw new InvalidOperationException("field is null.");
                }

                // add...
                fields.Add(field);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Adds a EntityField instance to the collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public void AddRange(EntityFieldCollection items)
 {
     this.AddRangeInternal(items);
 }