0

I am developing an application with open data hosted by socrata using the information from the below link http://dev.socrata.com/consumers/examples/creating-an-application-with-asp-dotnet.html How ever you need to specify the API end point in the code.

private const string _APIEndPoint4x4 = “4tka-6guv”;

Suppose there are 5000 records in the data set, it will list all the data in your applications. But you can change the end point by filtering this data by login in to socrata and saving it. For example we can filter the data say with year 2015 which will give us 100 records. When next time you run the application it will show only 100 records(We dont need to change API end point in code). I have gone through Soql query methods in Socrata which say you can set the api end points with conditions like this

https://soda.demo.socrata.com/resource/4tka-6guv?$where=magnitude > 3.0

My question is how can i use this in my application? I tried

private const string _APIEndPoint4x4 = "4tka-6guv?$where=magnitude > 3.0”;

But it gives the following error

The provided resourceId is not a valid Socrata (4x4) resource identifier.

4

3 回答 3

2

您可能会发现查看 PDF 指南中提到的 SODA.NET SDK 的自述文件中的文档很有用: https ://github.com/CityofSantaMonica/SODA.NET

要过滤数据,您可以使用如下代码:

var dataset = client.GetResource<MyClass>("4tka-6guv");
var soql = new SoqlQuery().Select("column1", "column2")
                      .Where("magnitude > 3.0");

var results = dataset.Query<MyOtherClass>(soql);
于 2015-05-14T20:52:05.733 回答
0

作为其他答案的后续行动......

每个数据集都有一个与之关联的资源标识符,也称为Socrata 4x4。在您的示例中,资源标识符4tka-6guv. 它始终是 4 个字母数字字符、一个破折号,然后是另外 4 个字母数字字符。因此名称为Socrata 4x4

错误信息:

提供的 resourceId 不是有效的 Socrata (4x4) 资源标识符。

表示您在代码中提供的 resourceId 格式不正确。这一行:

private const string _APIEndPoint4x4 = "4tka-6guv?$where=magnitude > 3.0”;

提供的不仅仅是 Socrata 4x4 - 您还有一个查询参数 ( $where=magnitude > 3.0)。

现在,在 Socrata 中获取对数据集的引用,a la

var dataset = client.GetResource<MyClass>("4tka-6guv");

只需要使用Socrata 4x4

这不会下载所有行,而只是为您提供一个对象来执行其他查询。要实际获取一些数据,请构建一个SoqlQuery对象以传递给您之前获得的引用的Query方法。dataset

这就是Adrian Laurenzi(通过SODA.NET README的方式)所展示的内容。

于 2015-06-08T20:39:03.430 回答
-1

该 PDF 中的第 14 页包含有关如何使用 SoQL 过滤器的一些详细信息和代码示例。试试看,如果有帮助,请告诉我!

于 2015-05-14T16:26:16.417 回答