Ejemplo n.º 1
0
 protected override Expression VisitNew(NewExpression node)
 {
     foreach (MemberExpression propertyExpression in node.Arguments.OfType <MemberExpression>())
     {
         var property = (PropertyInfo)propertyExpression.Member;
         if (TestContractResolver.IsEntity(property.PropertyType))
         {
             SelectProperties.Add(property);
         }
     }
     return(node);
 }
Ejemplo n.º 2
0
        public static void Compare(IList fromDb, IList fromOe, ModelBuilder.OeEdmModelMetadataProvider metadataProvider, IReadOnlyList <IncludeVisitor.Include> includes)
        {
            var contractResolver = new TestContractResolver(metadataProvider, includes);
            var settings         = new JsonSerializerSettings()
            {
                ContractResolver      = contractResolver,
                DateFormatString      = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'.'ffffff",
                DateTimeZoneHandling  = DateTimeZoneHandling.Utc,
                Formatting            = Newtonsoft.Json.Formatting.Indented,
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
                NullValueHandling     = NullValueHandling.Ignore
            };
            String jsonDb = JsonConvert.SerializeObject(fromDb, settings);

            contractResolver.DisableWhereOrder = true;
            String jsonOe = JsonConvert.SerializeObject(fromOe, settings);

            Assert.Equal(jsonDb, jsonOe);
        }
Ejemplo n.º 3
0
        public virtual async Task Execute <T, TResult>(QueryParameters <T, TResult> parameters)
        {
            IList fromOe = await ExecuteOe <TResult>(parameters.RequestUri, parameters.NavigationNextLink, parameters.PageSize).ConfigureAwait(false);

            ODataUri  odataUri = ParseUri(parameters.RequestUri);
            IEdmModel edmModel = EdmModel.GetEdmModel(odataUri.Path);

            Db.OeDataAdapter oeDataAdapter = edmModel.GetDataAdapter(edmModel.EntityContainer);
            Db.OeDataAdapter dbDataAdapter = ((ITestDbDataAdapter)oeDataAdapter).DbDataAdapter;

            IList fromDb;
            IReadOnlyList <IncludeVisitor.Include> includes;

            using (var dataContext = (DbContext)dbDataAdapter.CreateDataContext())
                fromDb = TestHelper.ExecuteDb(dbDataAdapter, dataContext, parameters.Expression, out includes);

            //fix null navigation property Order where aggregate Order(Name)
            if (typeof(TResult) == typeof(Object))
            {
                foreach (SortedDictionary <String, Object> item in fromOe)
                {
                    foreach (KeyValuePair <String, Object> keyValue in item.Where(i => i.Value == null).ToList())
                    {
                        PropertyInfo navigationProperty = typeof(T).GetProperty(keyValue.Key);
                        if (navigationProperty != null &&
                            TestContractResolver.IsEntity(navigationProperty.PropertyType) &&
                            !includes.Any(i => i.Property == navigationProperty))
                        {
                            item.Remove(keyValue.Key);
                        }
                    }
                }
            }

            Console.WriteLine(parameters.RequestUri);
            TestHelper.Compare(fromDb, fromOe, MetadataProvider, includes);
        }
Ejemplo n.º 4
0
 public EmptyCollectionValueProvider(TestContractResolver contractResolver, IValueProvider defaultValueProvider, Func <IEnumerable, IList> lambda)
 {
     _contractResolver     = contractResolver;
     _defaultValueProvider = defaultValueProvider;
     _lambda = lambda;
 }