public ManagedPropertyChangedEventArgs(IManagedProperty property, object oldValue, object newValue, ManagedPropertyChangedSource source) { this._property = property; this._oldValue = oldValue; this._newValue = newValue; this._source = source; }
/// <summary> /// 当实体的某个属性变更时,自动向父级实体的指定属性汇总。 /// </summary> /// <param name="entity">实体对象</param> /// <param name="changedPropertyArgs">实体属性变更时的参数</param> /// <param name="toTreeParent"> /// 如果实体是树型对象,那么这个参数表明是否需要把值汇总到树中的父对象的同一个属性值上。 /// </param> /// <param name="toParentProperty"> /// 指示需要把值汇总到组合父对象的哪一个属性上。这个属性只支持直接父对象,不支持多级父对象。 /// </param> /// <threadsafety static="true" instance="true"/> public static void AutoCollectAsChanged( Entity entity, ManagedPropertyChangedEventArgs changedPropertyArgs, bool toTreeParent = true, IManagedProperty toParentProperty = null ) { if (toTreeParent) { if (entity.IsTreeParentLoaded && entity.TreeParent != null) { CalculateCollectValue(entity.TreeParent, changedPropertyArgs.Property, changedPropertyArgs); //如果已经向树型父汇总,则不向父对象汇总,直接返回 return; } } if (toParentProperty != null) { var parent = entity.FindParentEntity(); if (parent != null) { CalculateCollectValue(parent, toParentProperty, changedPropertyArgs); } } }
private EntityPropertyViewMeta CreateEntityPropertyViewMeta(IManagedProperty mp, EntityViewMeta evm) { var item = evm.CreatePropertyViewMeta(); item.Owner = evm; item.PropertyMeta = evm.EntityMeta.Property(mp); //如果这个托管属性有对应的 CLR 属性,并且这个 CLR 属性上标记了 Label 标签,则设置元数据的 Label 属性。 var runtimeProperty = item.PropertyMeta.CLRProperty; if (runtimeProperty != null) { var labelAttri = runtimeProperty.GetSingleAttribute<LabelAttribute>(); if (labelAttri != null) item.Label = labelAttri.Label; } item.Readonly(mp.IsReadOnly || mp == EntityConvention.Property_TreeIndex); //如果是引用实体的属性,创建 SelectionViewMeta if (item.IsReference) { item.SelectionViewMeta = new SelectionViewMeta(); } evm.EntityProperties.Add(item); return item; }
/// <summary> /// 构造器。 /// </summary> /// <param name="property">托管属性</param> /// <param name="owner">该属性对应的具体类型。 /// 这个具体的类型必须是属性的拥有类型或者它的子类型。如果传入 null,则默认为属性的拥有类型。</param> /// <exception cref="System.ArgumentNullException">property</exception> public ConcreteProperty(IManagedProperty property, Type owner) { if (property == null) throw new ArgumentNullException("property"); if (owner == null) owner = property.OwnerType; this._property = property; this._owner = owner; }
/// <summary> /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。 /// </summary> /// <param name="query">查询.</param> /// <param name="property">要约束的属性.</param> /// <param name="op">约束条件操作符.</param> /// <param name="value">对比的值。</param> /// <returns></returns> public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value) { var source = query.MainTable; if (!property.OwnerType.IsAssignableFrom(source.EntityRepository.EntityType)) { source = query.From.FindTable(property.OwnerType); } return AddConstraint(query, property, op, value, source); }
internal EntityPropertyViewMeta CreateExtensionPropertyViewMeta(IManagedProperty mp, EntityViewMeta evm) { var epm = evm.EntityMeta.Property(mp); var epvm = evm.CreatePropertyViewMeta(); epvm.Owner = evm; epvm.PropertyMeta = epm; evm.EntityProperties.Add(epvm); return epvm; }
/// <summary> /// 通过属性查找对应的列 /// </summary> /// <param name="property"></param> /// <returns></returns> public TreeColumn FindColumnByProperty(IManagedProperty property) { foreach (var column in this.Columns) { var c = column as TreeColumn; if (c != null && c.Meta != null && c.Meta.PropertyMeta.ManagedProperty == property) { return c; } } return null; }
/// <summary> /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。 /// </summary> /// <param name="query">查询.</param> /// <param name="property">要约束的属性.</param> /// <param name="op">约束条件操作符.</param> /// <param name="value">对比的值。</param> /// <param name="propertySource">指定该属性所属的实体数据源。</param> /// <returns></returns> public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value, ITableSource propertySource) { var f = QueryFactory.Instance; var propertyNode = propertySource.Column(property); var where = f.Constraint(propertyNode, op, value); if (query.Where == null) { query.Where = where; } else { query.Where = f.And(query.Where, where); } return query; }
internal PropertyComparisonExpression(IManagedProperty property, Type concreteType, PropertyCompareOperator op, object value) : base(property, concreteType) { this.Operator = op; this.Value = value; switch (op) { case PropertyCompareOperator.Equal: case PropertyCompareOperator.NotEqual: break; default: if (value == null) { throw new InvalidOperationException("null 值只能进行相等、不相等两种对比。"); } break; } }
/// <summary> /// LoadProperty 以最快的方式直接加载值,不发生 PropertyChanged 事件。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> public override void LoadProperty(IManagedProperty property, object value) { base.LoadProperty(property, value); this.OnChildLoaded(property, value); }
/// <summary> /// 重设属性为默认值 /// </summary> /// <param name="property"></param> public void ResetProperty(IManagedProperty property) { this._ResetProperty(property); }
/// <summary> /// 添加某属性以某字符串值为模糊匹配的条件。 /// </summary> /// <param name="property">作为条件判断的属性。</param> /// <param name="value">作为比较的值。值中需要带有通配符。如 '%'</param> /// <param name="propertyOwner"> /// 如果该属性的声明者没有映射具体的表(例如该属性为抽象基类的属性),则需要指定 propertyOwner 为具体的子类。 /// </param> public void WriteLike(IManagedProperty property, string value, Type propertyOwner = null) { this.WriteConstrain(property, "like", value, propertyOwner); }
/// <summary> /// 检查某个属性是否满足规则 /// </summary> /// <param name="target">要验证的实体。</param> /// <param name="property">托管属性</param> /// <param name="actions">验证时的行为。</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">target /// or /// property</exception> public static BrokenRulesCollection Validate(this Entity target, IManagedProperty property, ValidatorActions actions) { return(Validate(target, property, actions, null)); }
private ValueProperty ConvertToValueProperty(IManagedProperty property) { var valueProperty = new ValueProperty(); valueProperty.Name = property.Name; var propertyType = property.PropertyType; //处理可空类型 if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) { propertyType = propertyType.GetGenericArguments()[0]; valueProperty.Nullable = true; } if (propertyType == typeof(string)) { valueProperty.PropertyType = ValuePropertyType.String; } else if (propertyType == typeof(bool)) { valueProperty.PropertyType = ValuePropertyType.Boolean; } else if (propertyType == typeof(int)) { valueProperty.PropertyType = ValuePropertyType.Int; } else if (propertyType == typeof(double)) { valueProperty.PropertyType = ValuePropertyType.Double; } else if (propertyType == typeof(DateTime)) { valueProperty.PropertyType = ValuePropertyType.DateTime; } else if (propertyType == typeof(byte[])) { valueProperty.PropertyType = ValuePropertyType.Bytes; } else if (propertyType.IsEnum) { valueProperty.PropertyType = ValuePropertyType.Enum; valueProperty.EnumType = AddEnumIf(propertyType); } else { valueProperty.PropertyType = ValuePropertyType.Unknown; } return valueProperty; }
private void VisitValueProperty(PropertyInfo clrProperty, IManagedProperty mp, IRepositoryInternal mpOwnerRepo) { //接下来,是一般属性的处理 if (_visitRefProperties) { throw OperationNotSupported(string.Format("不支持使用属性:{0}。这是因为它的拥有者是一个值属性,值属性只支持直接对比。", clrProperty.Name)); } //如果已经记录了条件的属性,那么当前的 mp 就是用于对比的第二个属性。(A.Code = A.Name 中的 Name) if (_propertyResult != null) { _rightPropertyResult = mp; _rightPropertyResultRepo = mpOwnerRepo; } //如果还没有记录属性,说明当前条件要比较的属性就是 mp;(A.Code = 1 中的 Code) else { _propertyResult = mp; _propertyResultRepo = mpOwnerRepo; } }
/// <summary> /// 根据名字查询实体属性 /// </summary> /// <param name="property"></param> /// <returns></returns> public EntityPropertyViewMeta Property(IManagedProperty property) { return(this.Property(property.Name)); }
public EntityPropertyViewMeta CreateExtensionPropertyViewMeta(IManagedProperty mp, EntityViewMeta evm) { return(this._codeReader.CreateExtensionPropertyViewMeta(mp, evm)); }
public void ClearRules(IManagedProperty property) { _propertyRulesList.Remove(property); }
protected override PropertyDescriptor CreateDescriptor(IManagedProperty mp) { return(new RafyPropertyDescriptor(mp)); }
/// <summary> /// 如果当前 Rafy 运行时环境中,已经拥有 UI 层界面的元数据,则获取属性对应的的显示名称,并进行翻译后返回。 /// 否则,直接返回以下格式的字符串,方便替换:[属性名称]。(服务端一般都没有 UI 层元数据。) /// </summary> /// <param name="property">The property.</param> /// <returns></returns> public static string Display(IManagedProperty property) { return(RuleArgs.Display(property)); }
/// <summary> /// 设置某个托管属性的值。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> /// <param name="source">本次值设置的来源。</param> /// <returns>返回最终使用的值。</returns> public virtual object SetProperty(IManagedProperty property, object value, ManagedPropertyChangedSource source = ManagedPropertyChangedSource.FromProperty) { return(this._SetProperty(property, value, source)); }
protected override Expression VisitMember(MemberExpression m) { //只能访问属性 var clrProperty = m.Member as PropertyInfo; if (clrProperty == null) throw EntityQueryBuilder.OperationNotSupported(m.Member); var ownerExp = m.Expression; if (ownerExp == null) throw EntityQueryBuilder.OperationNotSupported(m.Member); //exp 如果是: A 或者 A.B.C,都可以作为属性查询。 var nodeType = ownerExp.NodeType; if (nodeType != ExpressionType.Parameter && nodeType != ExpressionType.MemberAccess) throw EntityQueryBuilder.OperationNotSupported(m.Member); //如果是 A.B.C.Name,则先读取 A.B.C,记录最后一个引用实体类型 C;剩下 .Name 给本行后面的代码读取。 VisitRefEntity(ownerExp); //属性的拥有类型对应的仓库。 //获取当前正在查询的实体对应的仓库对象。如果是级联引用表达式,则使用最后一个实体即可。 var ownerTable = _query.MainTable; var ownerRepo = _repo; if (_lastJoinRefResult != null) { //如果已经有引用属性在列表中,说明上层使用了 A.B.C.Name 这样的语法。 //这时,Name 应该是 C 这个实体的值属性。 ownerRepo = RepositoryFactoryHost.Factory.FindByEntity(_lastJoinRefResult.RefEntityType); ownerTable = _lastJoinTable; _lastJoinRefResult = null; _lastJoinTable = null; } //查询托管属性 var mp = EntityQueryBuilder.FindProperty(ownerRepo, clrProperty); if (mp == null) throw EntityQueryBuilder.OperationNotSupported("Linq 查询的属性必须是一个托管属性。"); if (mp is IRefEntityProperty) { //如果是引用属性,说明需要使用关联查询。 var refProperty = mp as IRefEntityProperty; var refTable = f.FindOrCreateJoinTable(_query, ownerTable, refProperty); if (refProperty.Nullable) { var column = ownerTable.Column(refProperty.RefIdProperty); NullableRefConstraint = _reverseConstraint ? f.Or(NullableRefConstraint, column.Equal(null as object)) : f.And(NullableRefConstraint, column.NotEqual(null as object)); } //存储到字段中,最后的值属性会使用这个引用属性对应的引用实体类型来查找对应仓库。 _lastJoinRefResult = refProperty; _lastJoinTable = refTable; return m; } if (_visitRefProperties) { throw EntityQueryBuilder.OperationNotSupported(string.Format("不支持使用属性:{0}。这是因为它的拥有者是一个值属性,值属性只支持直接对比。", mp.Name)); } //访问值属性 PropertyOwnerTable = ownerTable; Property = mp; return m; }
/// <summary> /// 检查某个属性是否满足规则 /// </summary> /// <param name="target">要验证的实体。</param> /// <param name="property">托管属性</param> /// <param name="ruleFilter">要验证的规则的过滤器。</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">target /// or /// property</exception> public static BrokenRulesCollection Validate(this Entity target, IManagedProperty property, Func <IRule, bool> ruleFilter = null) { return(Validate(target, property, DefaultActions, ruleFilter)); }
/// <summary> /// 在View中寻找指定属性的Editor /// </summary> /// <param name="conView"></param> /// <param name="property">找这个属性对应的Editor</param> /// <returns></returns> public IPropertyEditor FindPropertyEditor(IManagedProperty property) { return(this._editors.FirstOrDefault(e => e.Meta.PropertyMeta.ManagedProperty == property)); }
/// <summary> /// 通过目前已经收集到的属性、操作符、值,来生成一个属性条件结果。 /// 并清空已经收集的信息。 /// </summary> private void MakeConstraint() { if (_propertyResult != null && _operator.HasValue) { if (_hasValueResult) { _whereResult = new PropertyConstraint { Context = _query, Property = _propertyResult, ConcreteType = _propertyResultRepo.EntityType, Operator = _operator.Value, Value = _valueResult }; _hasValueResult = false; } else { _whereResult = new TwoPropertiesConstraint { Context = _query, LeftProperty = _propertyResult, LeftPropertyOwner = _propertyResultRepo.EntityType, Operator = _operator.Value, RightProperty = _rightPropertyResult, RightPropertyOwner = _rightPropertyResultRepo.EntityType, }; _rightPropertyResult = null; _rightPropertyResultRepo = null; } _propertyResult = null; _propertyResultRepo = null; _operator = null; } }
/// <summary> /// 找到指定托管属性对应的 ORM 表元数据。 /// </summary> /// <param name="property">The property.</param> /// <param name="propertyOwner">The property owner.</param> /// <returns></returns> private DbTable GetDbTable(IManagedProperty property, Type propertyOwner) { return(GetPropertyTable(property, propertyOwner, this._tablesCache)); }
/// <summary> /// LoadProperty 以最快的方式直接加载值,不发生 PropertyChanged 事件。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> public override void LoadProperty(IManagedProperty property, object value) { if (property == IdProperty || property == TreePIdProperty && value != null) { //由于 Id 属性的托管属性类型是 object,这里需要强制为具体的主键类型。 value = TypeHelper.CoerceValue(this.KeyProvider.KeyType, value); } base.LoadProperty(property, value); this.OnChildLoaded(property, value); }
/// <summary> /// Initializes a new instance of the <see cref="NotUsedByReferenceRule"/> class. /// </summary> /// <param name="refProperty">可以是引用属性,也可以是冗余属性。.</param> public NotUsedByReferenceRule(IManagedProperty refProperty) { this.ReferenceProperty = new ConcreteProperty(refProperty); }
/// <summary> /// 检查某个属性是否满足规则 /// </summary> /// <param name="target">要验证的实体。</param> /// <param name="property">托管属性</param> /// <param name="actions">验证时的行为。</param> /// <param name="ruleFilter">要验证的规则的过滤器。</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">target /// or /// property</exception> public static BrokenRulesCollection Validate( this Entity target, IManagedProperty property, ValidatorActions actions, Func<IRule, bool> ruleFilter ) { if (target == null) throw new ArgumentNullException("target"); if (property == null) throw new ArgumentNullException("property"); var res = new BrokenRulesCollection(); //获取指定实体的规则容器 var rulesManager = ValidationHelper.GetTypeRules(target.FindRepository() as ITypeValidationsHost, target.GetType()); if (rulesManager != null) { // get the rules list for this property RulesContainer rulesList = rulesManager.GetRulesForProperty(property, false); if (rulesList != null) { // get the actual list of rules (sorted by priority) CheckRules(target, rulesList, res, actions, ruleFilter); } } return res; }
/// <summary> /// 使用托管属性及它的 OwnerType 作为 ConcreteType 来构造一个 ConcreteProperty。 /// </summary> /// <param name="property">托管属性</param> public ConcreteProperty(IManagedProperty property) : this(property, property.OwnerType) { }
/// <summary> /// 添加某属性包含某值的条件。 /// </summary> /// <param name="property">作为条件判断的属性。</param> /// <param name="value">作为比较的值。</param> /// <param name="propertyOwner"> /// 如果该属性的声明者没有映射具体的表(例如该属性为抽象基类的属性),则需要指定 propertyOwner 为具体的子类。 /// </param> public void WriteContains(IManagedProperty property, string value, Type propertyOwner = null) { this.WriteConstrain(property, "like", '%' + value + '%', propertyOwner); }
/// <summary> /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。 /// </summary> /// <param name="query">查询.</param> /// <param name="property">要约束的属性.</param> /// <param name="value">对比的值。</param> /// <returns></returns> public static IQuery AddConstraint(this IQuery query, IManagedProperty property, object value) { return(AddConstraint(query, property, PropertyOperator.Equal, value)); }
/// <summary> /// 添加某属性在某个序列中的条件。 /// </summary> /// <param name="property">作为条件判断的属性。</param> /// <param name="values">作为比较的值。</param> /// <param name="propertyOwner"> /// 如果该属性的声明者没有映射具体的表(例如该属性为抽象基类的属性),则需要指定 propertyOwner 为具体的子类。 /// </param> public void WriteIn(IManagedProperty property, IList values, Type propertyOwner = null) { this.WriteInCore(property, values, true, propertyOwner); }
public DbOrder(IManagedProperty property, bool asc) { this._property = property; this._asc = asc; }
private void VisitValueProperty(IManagedProperty mp, ITableSource mpOwnerTable) { //如果已经记录了条件的属性,那么当前的 mp 就是用于对比的第二个属性。(A.Code = A.Name 中的 Name) if (_propertyResult != null) { _rightPropertyResult = mpOwnerTable.Column(mp); } //如果还没有记录属性,说明当前条件要比较的属性就是 mp;(A.Code = 1 中的 Code) else { _propertyResult = mpOwnerTable.Column(mp); } }
public IColumnNode Column(IManagedProperty property, string alias) { var res = this.Column(property); res.Alias = alias; return res; }
/// <summary> /// 如果当前 Rafy 运行时环境中,已经拥有 UI 层界面的元数据,则获取属性对应的的显示名称,并进行翻译后返回。 /// 否则,直接返回以下格式的字符串,方便替换:[属性名称]。(服务端一般都没有 UI 层元数据。) /// </summary> /// <param name="property">The property.</param> /// <returns></returns> public static string Display(IManagedProperty property) { return RuleArgs.Display(property); }
/// <summary> /// 获取某个托管属性的值。 /// </summary> /// <param name="property"></param> /// <returns></returns> public object GetProperty(IManagedProperty property) { return(this._GetProperty(property)); }
/// <summary> /// 设置某个属性的值。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> /// <param name="source"></param> /// <returns>返回最终使用的值。</returns> private object _SetProperty(IManagedProperty property, object value, ManagedPropertyChangedSource source) { object finalValue = null; CheckEditing(property); var meta = property.GetMeta(this) as IManagedPropertyMetadataInternal; finalValue = meta.DefaultValue; value = CoerceType(property, value); bool isReset = false; if (NeedReset(property, value)) { isReset = true; value = meta.DefaultValue; } bool cancel = meta.RaisePropertyChangingMetaEvent(this, ref value, source); if (!cancel) { bool hasOldValue = false; object oldValue = null; //这个 if 块中的代码:查找或创建对应 property 的 field,同时记录可能存在的历史值。 if (property.LifeCycle == ManagedPropertyLifeCycle.Compile) { var index = property.TypeCompiledIndex; var field = this._compiledFields[index]; if (field.HasValue) { oldValue = field.Value; hasOldValue = true; } if (isReset) { this._compiledFields[index].ResetValue(); } else { this._compiledFields[index]._value = value; } } else { if (this._runtimeFields == null) { if (!isReset) { this._runtimeFields = new Dictionary <IManagedProperty, ManagedPropertyField>(); } } else { var oldField = new ManagedPropertyField(); if (this._runtimeFields.TryGetValue(property, out oldField)) { oldValue = oldField.Value; hasOldValue = true; } } if (isReset) { if (hasOldValue) { this._runtimeFields.Remove(property); } } else { //使用新的 field var field = new ManagedPropertyField { _property = property, _value = value }; if (hasOldValue) { this._runtimeFields[property] = field; } else { this._runtimeFields.Add(property, field); } } } if (!hasOldValue) { oldValue = meta.DefaultValue; } if (!object.Equals(oldValue, value)) { var args = new ManagedPropertyChangedEventArgs(property, oldValue, value, source); //发生 Meta 中的回调事件 meta.RaisePropertyChangedMetaEvent(this, args); //发生外部事件 this.RaisePropertyChanged(args); finalValue = value; } } return(finalValue); }
public EntityPropertyViewMeta CreateExtensionPropertyViewMeta(IManagedProperty mp, EntityViewMeta evm) { return this._codeReader.CreateExtensionPropertyViewMeta(mp, evm); }
/// <summary> /// LoadProperty 以最快的方式直接加载值,不发生 PropertyChanged 事件。 /// </summary> /// <param name="property"></param> /// <param name="value"></param> public virtual void LoadProperty(IManagedProperty property, object value) { this._LoadProperty(property, value); }
public IColumnNode Column(IManagedProperty property) { var res = this.FindColumn(property); if (res == null) throw new InvalidOperationException(string.Format("没有在实体数据源 {0} 中找到 {1} 属性对应的列。", this.GetName(), property.Name)); return res; }
/// <summary> /// 如果提供的值是不可空的,则为查询条件添加是否为起始字符串的查询判断。 /// </summary> /// <param name="query">The query.</param> /// <param name="property">查询某个属性。</param> /// <param name="value">当 value 不可空时,才添加查询判断。</param> /// <param name="propertyOwner">The property owner.</param> /// <returns></returns> public static IPropertyQuery AddConstrainStartWithIf(this IPropertyQuery query, IManagedProperty property, string value, Type propertyOwner = null) { if (ConditionalSql.IsNotEmpty(value)) { query.AddConstrain(property, propertyOwner).StartWith(value); } return(query); }
public IColumnNode FindColumn(IManagedProperty property) { for (int i = 0, c = _tableInfo.Columns.Count; i < c; i++) { var dbColumn = _tableInfo.Columns[i]; if (dbColumn.Property == property) { if (_columns == null) { _columns = new ColumnNode[_tableInfo.Columns.Count]; } var res = _columns[i]; //如果该位置的列还没有生成,则即刻生成一个该列的对象,并插入到数组对应的位置中。 if (res == null) { res = NewColumn(dbColumn); _columns[i] = res; } return res; } } //如有列都遍历完成,没有找到与 property 对应的列,则返回 null。 return null; }
/// <summary> /// 如果提供的值是不可空的,则为查询条件添加不相等的查询判断。 /// </summary> /// <param name="query">The query.</param> /// <param name="property">查询某个属性。</param> /// <param name="value">当 value 不可空时,才添加查询判断。</param> /// <param name="propertyOwner">The property owner.</param> /// <returns></returns> public static IPropertyQuery AddConstrainNotEqualIf(this IPropertyQuery query, IManagedProperty property, object value, Type propertyOwner = null) { if (ConditionalSql.IsNotEmpty(value)) { query.AddConstrain(property, propertyOwner).NotEqual(value); } return(query); }
public ManagedPropertyRuntime(IManagedProperty core) { _core = core; }
/// <summary> /// 根据名字查询实体属性 /// </summary> /// <param name="property"></param> /// <returns></returns> public new WPFEntityPropertyViewMeta Property(IManagedProperty property) { return(base.Property(property) as WPFEntityPropertyViewMeta); }
internal string Translate(IManagedProperty property) { return(this.Translate(property.Name)); }
private bool VisitMethod_Queryable(MethodCallExpression exp) { var args = exp.Arguments; if (args.Count == 2) { this.Visit(args[0]);//visit queryable var lambda = StripQuotes(args[1]) as LambdaExpression; var previousWhere = _whereResult; this.Visit(lambda.Body); switch (exp.Method.Name) { case LinqConsts.QueryableMethod_Where: //如果现在不是第一次调用 Where 方法,那么需要把本次的约束和之前的约束进行 And 合并。 if (_whereResult != null && previousWhere != null) { _whereResult = new AndOrConstraint { Context = _query, IsAnd = true, Left = previousWhere, Right = _whereResult }; } break; case LinqConsts.QueryableMethod_OrderBy: case LinqConsts.QueryableMethod_ThenBy: if (_propertyResult != null) { _query.OrderBy(_propertyResult, OrderDirection.Ascending); _propertyResult = null; } break; case LinqConsts.QueryableMethod_OrderByDescending: case LinqConsts.QueryableMethod_ThenByDescending: if (_propertyResult != null) { _query.OrderBy(_propertyResult, OrderDirection.Descending); _propertyResult = null; } break; default: break; } return true; } return false; }
public IPropertyQuery Greater(IManagedProperty property, Type propertyOwner = null) { AddConstraint(PropertyCompareOperator.Greater, property, propertyOwner); return(this); }
internal string Translate(IManagedProperty property) { return this.Translate(property.Name); }
public IPropertyQuery LessEqual(IManagedProperty property, Type propertyOwner = null) { AddConstraint(PropertyCompareOperator.LessEqual, property, propertyOwner); return(this); }
private void OnChildLoaded(IManagedProperty property, object value) { var component = value as IDomainComponent; if (component != null) { component.SetParent(this); component.MarkSaved(); if (property is IListProperty) { (value as EntityList).InitListProperty(property as IListProperty); } } }
/// <summary> /// 在当前查询所有可使用的表中检索指定属性拥有者对应的表。 /// </summary> /// <param name="property"></param> /// <param name="propertyOwner"></param> /// <returns></returns> internal RdbTable GetPropertyTable(IManagedProperty property, Type propertyOwner) { return(ConditionalSql.GetPropertyTable(property, propertyOwner, this._tablesCache)); }
/// <summary> /// 检查某个属性是否满足规则 /// </summary> /// <param name="target">要验证的实体。</param> /// <param name="property">托管属性</param> /// <param name="ruleFilter">要验证的规则的过滤器。</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">target /// or /// property</exception> public static BrokenRulesCollection Validate(this Entity target, IManagedProperty property, Func<IRule, bool> ruleFilter = null) { return Validate(target, property, DefaultActions, ruleFilter); }
/// <summary> /// 添加某属性比某值大的条件。 /// </summary> /// <param name="property">作为条件判断的属性。</param> /// <param name="value">作为比较的值。</param> /// <param name="propertyOwner"> /// 如果该属性的声明者没有映射具体的表(例如该属性为抽象基类的属性),则需要指定 propertyOwner 为具体的子类。 /// </param> public void WriteGreater(IManagedProperty property, object value, Type propertyOwner = null) { this.WriteConstrain(property, ">", value, propertyOwner); }
/// <summary> /// 检查某个属性是否满足规则 /// </summary> /// <param name="target">要验证的实体。</param> /// <param name="property">托管属性</param> /// <param name="actions">验证时的行为。</param> /// <returns></returns> /// <exception cref="System.ArgumentNullException">target /// or /// property</exception> public static BrokenRulesCollection Validate(this Entity target, IManagedProperty property, ValidatorActions actions) { return Validate(target, property, actions, null); }
/// <summary> /// 添加某属性 <![CDATA[<=]]> 某值的条件。 /// </summary> /// <param name="property">作为条件判断的属性。</param> /// <param name="value">作为比较的值。</param> /// <param name="propertyOwner"> /// 如果该属性的声明者没有映射具体的表(例如该属性为抽象基类的属性),则需要指定 propertyOwner 为具体的子类。 /// </param> public void WriteLessEqual(IManagedProperty property, object value, Type propertyOwner = null) { this.WriteConstrain(property, "<=", value, propertyOwner); }