/// <summary> /// Constructor. /// </summary> public EntityFieldEventArgs(EntityField entityField) { if (entityField == null) { throw new ArgumentNullException("entityField"); } _entityField = entityField; }
/// <summary> /// Adds a EntityField instance to the collection. /// </summary> /// <param name="item">The item to add.</param> public void Insert(int index, EntityField item) { if (item == null) { throw new ArgumentNullException("item"); } List.Insert(index, item); item.SetOrdinal(index); }
/// <summary> /// Constructor. /// </summary> /// <param name="field"></param> public FieldChangedEventArgs(object entity, EntityField field, object oldValue, object newValue) : base(entity) { if (field == null) { throw new ArgumentNullException("field"); } _field = field; }
/// <summary> /// Constructor. /// </summary> /// <param name="field"></param> /// <param name="direction"></param> public SortSpecification(EntityField field, SortDirection direction) { if (field == null) { throw new ArgumentNullException("field"); } _field = field; _direction = direction; }
/// <summary> /// Removes a EntityField item to the collection. /// </summary> /// <param name="item">The item to remove.</param> public void Remove(EntityField item) { if (item == null) { throw new ArgumentNullException("item"); } int index = IndexOf(item.Name); List.RemoveAt(IndexOf(item.Name)); }
/// <summary> /// Constructor. /// </summary> /// <param name="field"></param> public EntityFieldViewProperty(EntityField field) : base(field.EntityType) { if (field == null) { throw new ArgumentNullException("field"); } // set... _field = field; }
/// <summary> /// Constructor. /// </summary> /// <param name="field"></param> public EntityFieldPropertyDescriptor(EntityField field) : base(field.Name, new Attribute[] {}) { if (field == null) { throw new ArgumentNullException("field"); } // set... _field = field; }
/// <summary> /// Adds a EntityField instance to the collection. /// </summary> /// <param name="item">The item to add.</param> public int Add(EntityField item) { if (item == null) { throw new ArgumentNullException("item"); } int index = List.Add(item); this.OnFieldAdded(new EntityFieldEventArgs(item)); return(index); }
/// <summary> /// Discovers if the given item is in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>Returns true if the given item is in the collection.</returns> public bool Contains(EntityField item) { if (IndexOf(item) == -1) { return(false); } else { return(true); } }
/// <summary> /// Sorts the list using the given comparer. /// </summary> /// <param name="comparer"></param> public void Sort(int index, int count, EntityField field, CultureInfo culture) { if (field == null) { throw new ArgumentNullException("field"); } // check... this.AssertIsStrongCollection(); // get it... IComparer comparer = field.GetComparer(culture); this.Sort(index, count, comparer); }
/// <summary> /// Sets the given field to be DB null. /// </summary> /// <param name="entity"></param> /// <param name="field"></param> /// <returns></returns> public void SetDBNull(object entity, EntityField field) { if (entity == null) { throw new ArgumentNullException("entity"); } if (EntityType == null) { throw new ArgumentNullException("EntityType"); } this.EntityType.AssertIsOfType(entity); // return... ((Entity)entity).SetDBNull(field); }
/// <summary> /// Sorts the list using the given comparer. /// </summary> /// <param name="comparer"></param> public void Sort(EntityField field, CultureInfo culture, SortDirection direction) { if (field == null) { throw new ArgumentNullException("field"); } // check... this.AssertIsStrongCollection(); // get it... IComparer comparer = field.GetComparer(culture); this.Sort(comparer, direction); }
/// <summary> /// Gets an array of fields by name. /// </summary> /// <param name="names"></param> /// <param name="onNotFound"></param> /// <returns></returns> internal EntityField[] GetFields(string[] names, OnNotFound onNotFound) { if (names == null) { throw new ArgumentNullException("names"); } // loop... EntityField[] fields = new EntityField[names.Length]; for (int index = 0; index < names.Length; index++) { fields[index] = this.GetField(names[index], onNotFound); } // return... return(fields); }
/// <summary> /// Pushes a value back down to the underlying field. /// </summary> /// <param name="field"></param> /// <param name="value"></param> private void PushValue(EntityField field, object value) { if (field == null) { throw new ArgumentNullException("field"); } // get storage... IEntityStorage storage = this.Storage; if (storage == null) { throw new ArgumentNullException("storage"); } // get... storage.SetValue(this.Entity, field, value, SetValueReason.UserSet); }
/// <summary> /// Returns true if the given field is modified. /// </summary> /// <param name="entity"></param> /// <returns></returns> public bool IsModified(object entity, EntityField field) { if (entity == null) { throw new ArgumentNullException("entity"); } if (field == null) { throw new ArgumentNullException("field"); } if (EntityType == null) { throw new ArgumentNullException("EntityType"); } this.EntityType.AssertIsOfType(entity); // init... return(((Entity)entity).IsModified(field)); }
/// <summary> /// Gets the link fields. /// </summary> /// <returns></returns> public EntityField[] GetLinkFields() { // init? if (this._linkFields == null) { // mbr - 19/5/06 - locking... lock (_linkFieldNamesLock) { if (_linkFieldNames != null) { // check... if (EntityType == null) { throw new ArgumentNullException("EntityType"); } // create... EntityField[] fields = new EntityField[_linkFieldNames.Length]; for (int index = 0; index < _linkFieldNames.Length; index++) { fields[index] = this.EntityType.Fields.GetField(_linkFieldNames[index], OnNotFound.ThrowException); } // set... _linkFields = fields; // reset... _linkFieldNames = null; } else { throw new InvalidOperationException("_linkFieldNames and _linkFields are both null."); } } } // return... EntityField[] newFields = new EntityField[this._linkFields.Length]; _linkFields.CopyTo(newFields, 0); return(newFields); }
/// <summary> /// Gets a value from the instance. /// </summary> /// <param name="field"></param> /// <returns></returns> public void SetValue(object entity, EntityField field, object value, SetValueReason reason) { if (entity == null) { throw new ArgumentNullException("entity"); } if (field == null) { throw new ArgumentNullException("field"); } // check... if (EntityType == null) { throw new ArgumentNullException("EntityType"); } this.EntityType.AssertIsOfType(entity); // cast... ((Entity)entity).SetValue(field, value, reason); }
/// <summary> /// Gets a value from the instance. /// </summary> /// <param name="field"></param> /// <returns></returns> public object GetValue(object entity, EntityField field, ConversionFlags flags, FetchFlags fetchFlags) { if (entity == null) { throw new ArgumentNullException("entity"); } if (field == null) { throw new ArgumentNullException("field"); } // check... if (EntityType == null) { throw new ArgumentNullException("EntityType"); } this.EntityType.AssertIsOfType(entity); // cast... return(((Entity)entity).GetValue(field, flags, fetchFlags)); }
internal override EntityField GetEntityField(ExtendedPropertyDefinition property) { if (property == null) { throw new ArgumentNullException("property"); } // Now check we have a DBType for our type DbType dbType = ConversionHelper.GetDBTypeForClrType(this.Type); EntityField newField = null; if (dbType == DbType.String || dbType == DbType.StringFixedLength) { long size = property.Size; if (size <= 0) { // mbr - 25-09-2007 - this can only happen with legacy... if (Database.ExtensibilityProvider is FlatTableExtensibilityProvider) { size = FlatTableExtensibilityProvider.MaxStringPropertyLength; } else { // TODO: This method has not been implemented. Check whether it is a valid not implementated, or a code path that was not completed. throw new NotImplementedException(string.Format("Not implemented for '{0}'.", this.GetType())); } } newField = new EntityField(property.Name, property.NativeName, dbType, EntityFieldFlags.Nullable, size); } else { newField = new EntityField(property.Name, property.NativeName, dbType, EntityFieldFlags.Nullable); } // set... newField.SetExtendedPropertyDefinition(property); // return... return(newField); }
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); } }
/// <summary> /// Pulls the value from the entity. /// </summary> /// <param name="field"></param> /// <returns></returns> private object PullValue(EntityField field) { if (field == null) { throw new ArgumentNullException("field"); } // check... if (Entity == null) { throw new ArgumentNullException("Entity"); } // get storage... IEntityStorage storage = this.Storage; if (storage == null) { throw new ArgumentNullException("storage"); } // get... return(storage.GetValue(this.Entity, field)); }
/// <summary> /// Returns the index of the item in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>The index of the item, or -1 if it is not found.</returns> public int IndexOf(EntityField item) { return(List.IndexOf(item)); }
/// <summary> /// Sorts the list using the given comparer. /// </summary> /// <param name="comparer"></param> public void Sort(EntityField field, CultureInfo culture) { this.Sort(field, culture, SortDirection.Ascending); }
/// <summary> /// Gets a value from the instance. /// </summary> /// <param name="field"></param> /// <returns></returns> public object GetValue(object entity, EntityField field, ConversionFlags flags) { return(this.GetValue(entity, field, flags, FetchFlags.None)); }
/// <summary> /// Sorts the list using the given comparer. /// </summary> /// <param name="comparer"></param> public void Sort(EntityField field, SortDirection direction = SortDirection.Ascending) { this.Sort(field, Cultures.System, direction); }
/// <summary> /// Gets a value from the instance. /// </summary> /// <param name="field"></param> /// <returns></returns> public object GetValue(object entity, EntityField field) { // defer... return(this.GetValue(entity, field, FetchFlags.None)); }
/// <summary> /// Constructor. /// </summary> /// <param name="field"></param> public EntityFieldPropertyDescriptor(EntityField field, string format) : this(field) { _format = format; }
/// <summary> /// Constructor for entity field view with format /// </summary> /// <param name="field"></param> /// <param name="format"></param> public EntityFieldViewProperty(EntityField field, string format) : this(field) { _format = format; }
public override void AddExtendedPropertyToSelectStatement(SqlStatementCreator creator, SqlStatement statement, System.Text.StringBuilder builder, BootFX.Common.Entities.EntityField field) { // add it... builder.Append(statement.Dialect.FormatTableName(field.EntityType.NativeNameExtended)); builder.Append("."); builder.Append(statement.Dialect.FormatColumnName(field.Name)); }
public override void DemandLoad(object entity, EntityField[] fields) { if (entity == null) { throw new ArgumentNullException("entity"); } if (fields == null) { throw new ArgumentNullException("fields"); } if (fields.Length == 0) { throw ExceptionHelper.CreateZeroLengthArgumentException("fields"); } // check... if (EntityType == null) { throw new ArgumentNullException("EntityType"); } EntityType.AssertIsOfType(entity); // new? if (this.Storage.IsNew(entity) == true) { throw new InvalidOperationException("Entity is new."); } if (this.Storage.IsDeleted(entity, false) == true) { throw new InvalidOperationException("Entity has been physically deleted."); } // create a filter... object[] keyValues = this.Storage.GetKeyValues(entity); SqlFilter filter = SqlFilter.CreateGetByIdFilter(this.EntityType, keyValues); // jm - 14-07-2006 - Hacked - Matt to sort out if (filter == null) { throw new InvalidOperationException("filter is null."); } filter.IgnorePartitioning = true; // clear the fields... filter.Fields.Clear(); filter.Fields.AddRange(fields); // get values... object[] values = filter.ExecuteValues(); if (values == null) { throw new ArgumentNullException("values"); } // check... if (values.Length != fields.Length) { throw ExceptionHelper.CreateLengthMismatchException("values", "fields", values.Length, fields.Length); } // init and set... this.Storage.BeginInitialize(entity); try { for (int index = 0; index < fields.Length; index++) { // value... EntityField field = fields[index]; if (field == null) { throw new InvalidOperationException("field is null."); } object value = values[index]; // encrypted? //if(field.IsEncrypted) //{ // if(value == null) // value = new EncryptedValue(null, (byte[])null); // else if(value is DBNull) // value = new EncryptedValue(typeof(DBNull), (byte[])null); // else // { // // switch... // switch(field.DBType) // { // case DbType.String: // case DbType.StringFixedLength: // case DbType.AnsiString: // case DbType.AnsiStringFixedLength: // value = new EncryptedValue(field.Type, (string)value); // break; // default: // throw new NotSupportedException(string.Format("Cannot handle '{0}' ({1}).", field.DBType, field.DBType.GetType())); // } // } //} if ((field.DBType == DbType.AnsiStringFixedLength || field.DBType == DbType.StringFixedLength) && value is string) { value = ((string)value).TrimEnd(); } // set... this.Storage.SetValue(entity, field, value, SetValueReason.DemandLoad); } } finally { this.Storage.EndInitialize(entity); } }