Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #4 from veena-udayabhanu/master
Browse files Browse the repository at this point in the history
Fix the filter string issue to not include case('')/
  • Loading branch information
joeg committed Nov 25, 2013
2 parents 4a74fce + 59ef709 commit 665d7d6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 26 deletions.
27 changes: 1 addition & 26 deletions Lib/Common/Table/Queryable/ExpressionWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,13 @@ internal override Expression VisitMemberAccess(MemberExpression m)
}

Expression e = this.Visit(m.Expression);

if (m.Member.Name == "Value" && m.Member.DeclaringType.IsGenericType
&& m.Member.DeclaringType.GetGenericTypeDefinition() == typeof(Nullable<>))
{
return m;
}

if (!IsInputReference(e))
if (!IsInputReference(e) && e.NodeType != ExpressionType.Convert && e.NodeType != ExpressionType.ConvertChecked)
{
this.builder.Append(UriHelper.FORWARDSLASH);
}
Expand Down Expand Up @@ -266,30 +265,6 @@ internal override Expression VisitUnary(UnaryExpression u)
break;
case ExpressionType.Convert:
case ExpressionType.ConvertChecked:
if (u.Type != typeof(object))
{
this.builder.Append(UriHelper.CAST);
this.builder.Append(UriHelper.LEFTPAREN);
if (!IsInputReference(u.Operand))
{
this.Visit(u.Operand);
this.builder.Append(UriHelper.COMMA);
}

this.builder.Append(UriHelper.QUOTE);
this.builder.Append(this.TypeNameForUri(u.Type));
this.builder.Append(UriHelper.QUOTE);
this.builder.Append(UriHelper.RIGHTPAREN);
}
else
{
if (!IsInputReference(u.Operand))
{
this.Visit(u.Operand);
}
}

break;
case ExpressionType.UnaryPlus:
break;
default:
Expand Down
34 changes: 34 additions & 0 deletions Test/ClassLibraryCommon/Table/TableQueryableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,40 @@ public void MyTestCleanup()
#region Query Segmented

#region Sync
[TestMethod]
[Description("IQueryable - A test to validate basic table query")]
[TestCategory(ComponentCategory.Table)]
[TestCategory(TestTypeCategory.UnitTest)]
[TestCategory(SmokeTestCategory.NonSmoke)]
[TestCategory(TenantTypeCategory.DevStore), TestCategory(TenantTypeCategory.DevFabric), TestCategory(TenantTypeCategory.Cloud)]
public void TableQueryableExecuteQueryGeneric()
{
currentTable = tableClient.GetTableReference(GenerateRandomTableName());
currentTable.CreateIfNotExists();

BaseEntity entity = new BaseEntity("mypk", "myrk");
TableOperation operation = TableOperation.Insert(entity);
currentTable.Execute(operation);

IQueryable<BaseEntity> query = currentTable.CreateQuery<BaseEntity>().Where(x => x.PartitionKey == "mypk");
foreach (BaseEntity ent in query.ToList())
{
Assert.AreEqual("mypk", ent.PartitionKey);
}

IEnumerable<BaseEntity> entities1 = GetEntities<BaseEntity>(currentTable, "mypk");
foreach (BaseEntity ent in entities1)
{
Assert.AreEqual("mypk", ent.PartitionKey);
}
}

private IEnumerable<T> GetEntities<T>(CloudTable table, string id) where T : ITableEntity, new()
{
IQueryable<T> query = table.CreateQuery<T>()
.Where(x => x.PartitionKey == "mypk");
return query.ToList();
}

[TestMethod]
[Description("IQueryable - A test to validate basic table query")]
Expand Down

0 comments on commit 665d7d6

Please sign in to comment.