/// <summary> Содаёт объект-"пустышку" </summary> public static DBObject GetEmpty(DBEntity entity, id ID) { //Создаём объект DBObject Result = (DBObject)entity.EntityType.GetConstructor(new Type[0]).Invoke(new object[0]); //Задаём инициализацию по-умолчанию для нового объекта Result.EmptyInitialization(); //Устанавливаем заданный идентификатор Result.ID = ID; return(Result); }
/// <summary> Метод "Get" для свойств, имеющих тип DBObject[], которые содержут объекты, ссылающиеся на данный объект через связь "Многие-ко-многим" </summary> protected T[] GetBindedArrayPropertyValue <T>(DBEntity manyToManyEntity) where T : DBObject { EntityAttribute entityAttribute = manyToManyEntity.EntityType.GetAttribute <EntityAttribute>(); if (!entityAttribute.HasTypes(this.GetType(), typeof(T))) { throw new ArgumentException("Неверно указны обобщенный параметр или manyToManyEntity"); } PropertyInfo thisTypeProperty = manyToManyEntity.EntityType.GetProperty(this.GetType().Name); PropertyInfo otherTypeProperty = manyToManyEntity.EntityType.GetProperty(typeof(T).Name); return(this.DataStorage.GetDBObjects(manyToManyEntity) .Where(x => thisTypeProperty.GetValue(x, null) == this) .Select(x => otherTypeProperty.GetValue(x, null)).Cast <T>().ToArray()); }