0
votes

I have two tables:

T1 with attributes: commonG, g1, g3,g7,g8
T2 with attributes: commonG, g2,g5,g6

WHERE T1.commonG is same as T2.commonG, for this query:

select t1.commonG, T1.g1, T2.g2
from T1 and T2
where T1.g3=777 and T1.commonG=T2.commonG

so I want to access this select data using an odataquery for some g3 value.

1

1 Answers

2
votes

An OData query is dependent upon an EDM model that understands that there is a foreign key relationship between T1.commonG and T2.commonG. Assuming you have such a model, there are three things you'll need:

  • The $select system query option allows you to do projections, e.g., $select=Name,Category/Name
  • The $expand system query option allows you to specify projections that come from two different tables (think of this as satisfying the logical join in your query above)
  • The $filter system query option allows you to specify the equivalent of the where clause above

One practical example in the real world is the following query: http://services.odata.org/Experimental/OData/OData.svc/Products?$expand=Category&$filter=Category/Name%20eq%20'Food'&select=Name,Category/Name

If you map your T1 to Product from the sample service and your T2 to Category from the sample service, you'll find that this sample is very close to what you actually want to achieve.