Exemplo n.º 1
0
 public void SameKeyProvidedTwiceInOneWhereClauseShouldReturnError()
 {
     // Provide both key properites in single where clause
     query = context.CreateQuery <DerivedEntityWithTwoKeyProperties>("Test")
             .Where(p => p.ID1 == 1 && p.ID1 == 2)
             .ToString();
     Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_CanOnlyApplyOneKeyPredicate), query);
 }
Exemplo n.º 2
0
        public void WhereClausesForKeysAndNonKeysAndSelectForNavPropertyShouldReturnError()
        {
            // Provide all key properties for entity and select a navigational entity
            query = context.CreateQuery <EntityWithTwoKeyProperties>("Test")
                    .Where(p => p.ID1 == 1).Where(p => p.Name == "foo").Where(p => p.ID2 == 2)
                    .Select(p => p.NavProperty)
                    .ToString();

            Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_QueryOptionsOnlyAllowedOnLeafNodes), query);
        }
Exemplo n.º 3
0
 /// <summary>Represents the URI of the query to the data service.</summary>
 /// <returns>A URI as string that represents the query to the data service for this <see cref="T:Microsoft.OData.Client.DataServiceQuery`1" /> instance.</returns>
 public override string ToString()
 {
     try
     {
         return(this.QueryComponents(this.Context.Model).Uri.ToString());
     }
     catch (NotSupportedException e)
     {
         return(Strings.ALinq_TranslationError(e.Message));
     }
 }
Exemplo n.º 4
0
 public void WhereClausesWithDuplicateKeysShouldReturnError()
 {
     // Add duplicate key property
     query = context.CreateQuery <EntityWithThreeKeyProperties>("Test")
             .Where(p => p.ID2 == "bar")
             .Where(p => p.ID1 == 2)
             .Where(p => p.ID3 == this.sampleDateTimeOffset)
             .Where(p => p.ID1 == 2)
             .ToString();
     Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_CanOnlyApplyOneKeyPredicate), query);
 }
Exemplo n.º 5
0
        public void ProjectionQueryToAnonymousTypeWithOrderByClauseShouldThrowError()
        {
            query = context.CreateQuery <EntityWithThreeKeyProperties>("Test")
                    .Select(p => new
            {
                ID1  = p.ID1,
                Name = p.Name
            })
                    .OrderBy(dummy => dummy.Name)
                    .ToString();

            Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_QueryOptionOutOfOrder("orderby", "select")), query);
        }
Exemplo n.º 6
0
        public void ProjectionQueryToAnonymousTypeWithWhereClauseShouldThrowError()
        {
            query = context.CreateQuery <EntityWithThreeKeyProperties>("Test")
                    .Select(p => new
            {
                ID1  = p.ID1,
                Name = p.Name
            })
                    .Where(anon => anon.ID1 > 1)
                    .ToString();

            Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_QueryOptionOutOfOrder("filter", "select")), query);
        }
Exemplo n.º 7
0
        public void ProjectionQueryToCreateNewTypeWithWhereClauseShouldThrowError()
        {
            query = context.CreateQuery <EntityWithThreeKeyProperties>("Test")
                    .Select(p => new DummyEntityWithOneKey
            {
                ID1  = p.ID1,
                Name = p.Name
            })
                    .Where(oneKey => oneKey.AnotherProperty > 1)
                    .ToString();

            Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_QueryOptionOutOfOrder("filter", "select")), query);
        }
Exemplo n.º 8
0
        public void ThreeKeys_WhereClausesForKeysForEntityAndSelectForNavPropertyWithWhereClauseShouldReturnError()
        {
            // Provide all key properties for entity and select a navigational entity
            query = context.CreateQuery <EntityWithThreeKeyProperties>("Test")
                    .Where(p => p.ID1 == 1)
                    .Where(p => p.ID2 == "foo")
                    .Where(p => p.ID3 == this.sampleDateTimeOffset)
                    .Select(p => p.NavProperty)
                    .Where(p => p.NonKeyProperty == "bar")
                    .ToString();

            Assert.AreEqual(Strings.ALinq_TranslationError(Strings.ALinq_QueryOptionsOnlyAllowedOnSingletons), query);
        }