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); }
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); }
/// <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)); } }
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); }
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); }
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); }
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); }
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); }