コード例 #1
0
        private void TestCast <TParam, TReturn>(CollectionResourceNode source, IEdmEntityType cast, Expression <Func <TParam, TReturn> > expectedExpression)
        {
            var node   = new CollectionResourceCastNode(source, cast);
            var result = this.testSubject.TranslateNode(node);

            CompareExpressions(expectedExpression.Body, result);
        }
コード例 #2
0
        private static string GetNavigationPath(CollectionResourceNode nodeIn)
        {
            if (nodeIn.NavigationSource == null)
            {
                return(string.Empty);
            }

            var pathSegments = nodeIn.NavigationSource.Path.PathSegments.Skip(1).ToArray();
            var path         = string.Join(Constants.SymbolDot, pathSegments);

            return(string.IsNullOrWhiteSpace(path) ? string.Empty : $"{path}{Constants.SymbolDot}");
        }
コード例 #3
0
        public void TranslatorShouldConvertWeaklyBackedEntityCollectionCast()
        {
            CollectionResourceNode source = this.CollectionNavigationFromParameter("c");
            QueryNode node   = new CollectionResourceCastNode(source, this.weaklyBackedCustomerEdmType);
            var       result = this.testSubject.TranslateNode(node);

            var parameterExpression = Expression.Parameter(typeof(Customer), "c");
            var propertyExpression  = Expression.Property(parameterExpression, "OtherFriends");
            var expected            = Expression.Call(typeof(DataServiceProviderMethods), "OfType", new[] { typeof(Customer), typeof(object) }, propertyExpression, Expression.Constant(this.weaklyBackedDerivedType));

            expected = Expression.Call(typeof(Enumerable), "Cast", new[] { typeof(object) }, expected);
            CompareExpressions(expected, result);
        }