从无主键视图(或存储过程)创建 ADO.NET 实体
使用视图和/或存储过程,我可以返回对 SQL Analysis Services 执行 MDX 查询的结果(对链接到 SQL 的 SSAS 服务器使用 OPENROWSET)。
不幸的是,结果集不包含 PK 字段……或者就此而言,如果我要破解模型,甚至可以充当 PK 的列。
任何人都可以想到我可以使用的黑客技巧:
- 在我的结果中添加一个字段,该字段插入一些自动递增值(充当 PK 候选者)
- 以某种方式将此字段设置为 PK,以便我可以轻松地构建一个实体它的?
我99%确信答案是“不”。此时,我已经可以通过使用带有 OData 渲染的 SSRS 报告从 SSAS 获取数据...但是当我使用 play w/LINQ 时,我必须手动创建类型。
如果有人能钉住#1 & #2 对我来说,这可能是访问数据的更好方法,因为建模器会为我创建类型(实体)。
谢谢!
Using either a view and/or stored procedure, I can return the results of executing an MDX query against SQL Analysis Services (using OPENROWSET against a linked SSAS Server into SQL).
Unfortunately, the resultset doesn't include a PK field...or for that matter, even a column which COULD act as a PK if I were to hack the model.
Can anyone think of a hacktacular trick I can use to:
- Add a field to my result which inserts some auto-incrementing value (to act as a PK candidate)
- Somehow set this field to be the PK so that I can easily build an entity off of it?
I'm 99% sure the answer is "no". At this point I can already get data back from SSAS by using an SSRS report with OData rendering...but I have to create my types manually when I use play w/ LINQ.
If someone can nail #1 & #2 for me, this may be a potentially better way to access the data since the Modeler would create my types (entities) for me.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否理解为什么不能有一个可以充当主键的列。我刚刚对过滤到成员列表的一个多维数据集运行了类似的查询,并且每个列名称都包含成员名称。下面是一个例子:
提交:
返回:
I'm not sure I understand why you can't have a column that could act as a primary key. I just ran a similar query against one of my cubes filtered to a list of members and each column name contained the member name. Here is an example:
Submission:
Returned: