private bool TryLoadProperty_Client(object entity, string propertyName, out object propertyValue) { propertyValue = null; Type type = entity.GetType(); if (!type.GetCustomAttributes(typeof(KeyAttribute), true).Any()) { return(false); } PropertyInfo property = type.GetProperty(propertyName); if (propertyName == null) { return(false); } WebDataCtxWrapper ctx = WebDataCtxWrapper.MostRecentContext; ctx.LoadProperty(entity, propertyName); propertyValue = property.GetValue(entity, null); return(true); }
protected void QueryLoadProperty(Func <IEdmEntityType, List <string> > getNavPropsLambda, bool workspaceShouldUpdate) { foreach (EntityDescriptor entityDec in CurrentContext.UnderlyingContext.Entities) { IEdmEntityType entityType = DataServiceMetadata.EntityTypes.FirstOrDefault(eType => eType.Name == entityDec.Entity.GetType().Name); foreach (string collNavProperty in getNavPropsLambda(entityType)) { AstoriaTestLog.WriteLine("Loading Properties {0}", collNavProperty); CurrentContext.LoadProperty(entityDec.Entity, collNavProperty); VerifyLoadProperty(entityDec.Entity, collNavProperty, CurrentContext); } } }