我正在使用Azure和Web API开发应用程序后端。为此,我创建了一些Azure表。以下是我的模型示例。
Could not find file for texture Big_Ben_spec.png
2016-12-13 16:40:37.546 GPS Sample[13723:834618] RootNode ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.001160, -0.000000, 0.001221)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:37.547 GPS Sample[13723:834618] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:39.877 GPS Sample[13723:834618] generated main fbo 2
2016-12-13 16:40:39.885 GPS Sample[13723:834618] created main FBO with width 1536 and height 2048
2016-12-13 16:40:40.281 GPS Sample[13723:834682] camera dimensions: 480.000000 x 640.000000
2016-12-13 16:40:40.282 GPS Sample[13723:834682] camera aspect ratio: 0.750000
2016-12-13 16:40:40.282 GPS Sample[13723:834682] framebuffer aspect ratio: 0.750000
2016-12-13 16:40:40.288 GPS Sample[13723:834682] rotating to orientation 1
2016-12-13 16:40:40.444 GPS Sample[13723:834682] WARNING: Could not find file for texture Big_Ben_diffuseShade.png
2016-12-13 16:40:40.444 GPS Sample[13723:834682] WARNING: Could not find file for texture Big_Ben_spec.png
2016-12-13 16:40:40.461 GPS Sample[13723:834682] RootNode ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:40.461 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.001160, -0.000000, 0.001221)
2016-12-13 16:40:40.462 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:40.462 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:40.462 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:40.462 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:40.462 GPS Sample[13723:834682] Big_Ben_001 ARVector3(0.000000, 0.000000, 0.000000)
2016-12-13 16:40:49.263 GPS Sample[13723:834618] Error while getting core location : (null)
分区键是使用表名称形成的,如UD_Device(UD_是常量,Device是表名.Row键只是所有设备唯一的DeviceName。
现在,当我在Web API中查询这些表时,我获得了一个实体列表以及分区键和行键作为其中的属性。
此列表我必须将其作为JSON提供给前端角度应用程序,但在执行此操作时不会发送分区键和行键。
当我发出POST请求时,即当我从角度前端获取数据并且我必须将其发送到Azure Table时,用户不会发送分区键和行键。那么我怎样才能制作满足这一要求的模型呢?
答案 0 :(得分:0)
此列表我必须将其作为JSON提供给前端角度应用程序,但在执行此操作时不会发送分区键和行键。
在我的示例中,我可以通过从AngularJS客户端应用程序调用Web API来获取所有实体属性(包括分区键和行键)。以下示例代码供您参考。
Web API
public class studentEntity : TableEntity
{
public studentEntity(string lastName, string firstName)
{
this.PartitionKey = lastName;
this.RowKey = firstName;
}
public studentEntity() { }
public int Age { get; set; }
}
public List<studentEntity> Get()
{
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("student");
TableQuery<studentEntity> rangeQuery = new TableQuery<studentEntity>().Where(
TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "Harp"));
List<studentEntity> list = table.ExecuteQuery(rangeQuery).ToList();
return list;
}
AngularJS
app.controller('myCtrl', function ($scope, $http) {
$http.get("http://XXX/api/values")
.then(function (response) {
$scope.mydata = response.data;
});
});
如果我的示例代码无法帮助您找到示例的问题,您可以与我们分享您的Web API代码(检索实体和返回实体列表)和AngularJS(向Web API发送请求)。然后我们将根据您的代码重现该问题。
答案 1 :(得分:-1)
您正在寻找的是数据传输对象。
AutoMapper等库可以让这个过程变得更加容易。