Webapi: OData - Enable querying of untyped objects

Created on 12 Jan 2015  路  2Comments  路  Source: OData/WebApi

Is it possible to add functionality to enable querying of untyped objects e.g.
dictionaries?

Code

[Queryable]
public List<Dictionary<string, object>> Get()
{
    var testSource = new List<Dictionary<string, object>>();
    for (var i = 0; i < 3; i++)
    {
        var e = new Dictionary<string, object>();
        e["Id"] = i;
        e["Notes"] = "Lorem Ipsum " + i;
        e["Date"] = new DateTime(1988 + i, 02, 02);

        testSource.Add(e);
    }

    return testSource;
}

Output

[
  {
    "Id": 0,
    "Notes": "Lorem Ipsum 0",
    "Date": "1988-02-02T00:00:00Z"
  },
  {
    "Id": 1,
    "Notes": "Lorem Ipsum 1",
    "Date": "1989-02-02T00:00:00Z"
  },
  {
    "Id": 2,
    "Notes": "Lorem Ipsum 2",
    "Date": "1990-02-02T00:00:00Z"
  }
]

How hard would it be to implement querying for following scenario? It would be
awesome for querying key/value stores that are taken from database and you
have no knowing beforehand what keys and values you have. Right now there is
no option to query these types of objects/dictionaries.

Work Item Details

Original CodePlex Issue: Issue 1310
Status: Proposed
Reason Closed: Unassigned
Assigned to: Unassigned
Reported on: Sep 20, 2013 at 6:42 PM
Reported by: StanislavRomanov
Updated on: Nov 5, 2013 at 1:36 PM
Updated by: stefjnl

P2 feature

Most helpful comment

+1

Very much needed. Need [Queryable] to work over untyped (non CLR) object like following.


var keyProperty = productEntity.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32);
productEntity.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
productEntity.AddStructuralProperty("Price", EdmPrimitiveTypeKind.Double);
productEntity.AddStructuralProperty("Category", EdmPrimitiveTypeKind.String);

Would LinqToQuerystring work on above kind of untyped object?

All 2 comments

+1

This is very much needed. However right now we have plugins like https://github.com/Roysvork/LinqToQuerystring that can accomplish this.

+1

Very much needed. Need [Queryable] to work over untyped (non CLR) object like following.


var keyProperty = productEntity.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32);
productEntity.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
productEntity.AddStructuralProperty("Price", EdmPrimitiveTypeKind.Double);
productEntity.AddStructuralProperty("Category", EdmPrimitiveTypeKind.String);

Would LinqToQuerystring work on above kind of untyped object?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

VikingsFan picture VikingsFan  路  5Comments

MDzyga picture MDzyga  路  5Comments

christiannagel picture christiannagel  路  4Comments

kpko picture kpko  路  3Comments

LianwMS picture LianwMS  路  5Comments