diff --git a/Lib/Common/Table/Queryable/ExpressionWriter.cs b/Lib/Common/Table/Queryable/ExpressionWriter.cs index b342a79fe..7dcf8b658 100644 --- a/Lib/Common/Table/Queryable/ExpressionWriter.cs +++ b/Lib/Common/Table/Queryable/ExpressionWriter.cs @@ -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); } @@ -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: diff --git a/Test/ClassLibraryCommon/Table/TableQueryableTests.cs b/Test/ClassLibraryCommon/Table/TableQueryableTests.cs index baa649acc..07fcabb30 100644 --- a/Test/ClassLibraryCommon/Table/TableQueryableTests.cs +++ b/Test/ClassLibraryCommon/Table/TableQueryableTests.cs @@ -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 query = currentTable.CreateQuery().Where(x => x.PartitionKey == "mypk"); + foreach (BaseEntity ent in query.ToList()) + { + Assert.AreEqual("mypk", ent.PartitionKey); + } + + IEnumerable entities1 = GetEntities(currentTable, "mypk"); + foreach (BaseEntity ent in entities1) + { + Assert.AreEqual("mypk", ent.PartitionKey); + } + } + + private IEnumerable GetEntities(CloudTable table, string id) where T : ITableEntity, new() + { + IQueryable query = table.CreateQuery() + .Where(x => x.PartitionKey == "mypk"); + return query.ToList(); + } [TestMethod] [Description("IQueryable - A test to validate basic table query")]