Neel
Neel

Reputation: 11

How to use contains in Azure table Linq query?

I have a Property with the value "This is my Red car" in my Azure Table. I have to get the records which contains Red in it, so I was trying to add string.contains("Red") in the TableQuery.

However, it's not working.

Any suggestions of some other ways to retrieve records which contains "Red"? I have:

var CarLog= client.GetTableReference("CarLog");
query = (from entry in CarLog.CreateQuery<CarEntity>()
where entry.PartitionKey.Equals(formattedDate)
&& entry.Subject.Contains("red")
select entry).Take(10) as TableQuery<CarEntity>;

Upvotes: 1

Views: 2662

Answers (2)

sly_Chandan
sly_Chandan

Reputation: 3515

You could go for the following code:

 TableQuery<BookEntity> bookQuery = table.CreateQuery<BookEntity>();
            var query = (from book in bookQuery
                         where book.RowKey.CompareTo("Agile") >= 0
                         select book).AsTableQuery();
            var books = query.Execute();

Upvotes: 0

Jason Hogg - MSFT
Jason Hogg - MSFT

Reputation: 1378

The Table Service only supports a subset of Linq functionality including a limited set of comparison operators (greater than, greater than or equal, less than, less than or equal, equal, and not equal) to use in the where clause. For more information see the Retrieving Multiple Entities using Lync section in the Table Design Guide.

Upvotes: 2

Related Questions