private void ExpandProperty(PropertyInfo p) { if (p.PropertyType.IsValueType || p.PropertyType == typeof(string)) { return; } string name = p.Name + "Reference"; PropertyInfo px = p.DeclaringType.GetProperty(name); if (px == null) { return; } ExpressionResult currentItem = ExpressionStack.Pop(); IRelatedEnd end = px.GetValue(currentItem.Result, null) as IRelatedEnd; end.Load(); object propertyValue = p.GetValue(currentItem.Result, null); if (ExpressionStack.Count > 0) { ExpressionStack.Peek().Result = propertyValue; } }
private static IEnumerable <TEntity> ExtractValues <TEntity>(IRelatedEnd relatedEnd) where TEntity : class { if (!relatedEnd.IsLoaded) { relatedEnd.Load(); } if (relatedEnd is IEnumerable enumerable) { return(ExtractCollection <TEntity>(enumerable)); } else { return(ExtractSingle <TEntity>(relatedEnd)); } }
private void AttachRelationOneEntity(FBEntity entity, IRelatedEnd re) { //Type t = re.GetType(); //Type eType = t.GetGenericArguments()[0]; if (re.IsLoaded) { return; } re.Load(); //RelationOneEntity rOneE = new RelationOneEntity(); //rOneE.EntityType= eType.Name; //rOneE.RelationshipName = re.RelationshipName; //rOneE.PropertyName = re.TargetRoleName; //entity.ReferencedEntity.Add(rOneE); //foreach (var item in re) //{ // FBEntity tempEntity = new FBEntity(); // tempEntity.Entity = item as EntityObject; // rOneE.FBEntity = tempEntity; // // re.Remove(item as IEntityWithRelationships); //} }
private void AttachRelationManyEntity(FBEntity entity, IRelatedEnd re) { Type t = re.GetType(); Type eType = t.GetGenericArguments()[0]; if (!re.IsLoaded) { re.Load(); } RelationManyEntity rManyE = new RelationManyEntity(); rManyE.EntityType = eType.Name; rManyE.RelationshipName = re.RelationshipName; rManyE.PropertyName = re.TargetRoleName; entity.CollectionEntity.Add(rManyE); foreach (var item in re) { FBEntity tempEntity = new FBEntity(); tempEntity.Entity = item as EntityObject; rManyE.FBEntities.Add(tempEntity); } //rManyE.FBEntities.ForEach(item => // { // try // { // IEntityWithRelationships ie = item.Entity as IEntityWithRelationships; // re.Remove(ie); // } // catch (Exception ex) // { // } // }); }
private void AttachRelationManyEntity(FBEntity entity, IRelatedEnd re) { Type t = re.GetType(); Type eType = t.GetGenericArguments()[0]; if (!re.IsLoaded) re.Load(); RelationManyEntity rManyE = new RelationManyEntity(); rManyE.EntityType = eType.Name; rManyE.RelationshipName = re.RelationshipName; rManyE.PropertyName = re.TargetRoleName; entity.CollectionEntity.Add(rManyE); foreach (var item in re) { FBEntity tempEntity = new FBEntity(); tempEntity.Entity = item as EntityObject; rManyE.FBEntities.Add(tempEntity); } //rManyE.FBEntities.ForEach(item => // { // try // { // IEntityWithRelationships ie = item.Entity as IEntityWithRelationships; // re.Remove(ie); // } // catch (Exception ex) // { // } // }); }
private void AttachRelationOneEntity(FBEntity entity, IRelatedEnd re) { //Type t = re.GetType(); //Type eType = t.GetGenericArguments()[0]; if (re.IsLoaded) return; re.Load(); //RelationOneEntity rOneE = new RelationOneEntity(); //rOneE.EntityType= eType.Name; //rOneE.RelationshipName = re.RelationshipName; //rOneE.PropertyName = re.TargetRoleName; //entity.ReferencedEntity.Add(rOneE); //foreach (var item in re) //{ // FBEntity tempEntity = new FBEntity(); // tempEntity.Entity = item as EntityObject; // rOneE.FBEntity = tempEntity; // // re.Remove(item as IEntityWithRelationships); //} }
/// <summary> /// Calls Load on the underlying <see cref="IRelatedEnd" />. /// </summary> public virtual void Load() { ValidateNotDetached("Load"); _relatedEnd.Load(); }