从无主键视图(或存储过程)创建 ADO.NET 实体

发布于 2024-09-10 02:00:44 字数 456 浏览 5 评论 0原文

使用视图和/或存储过程,我可以返回对 SQL Analysis Services 执行 MDX 查询的结果(对链接到 SQL 的 SSAS 服务器使用 OPENROWSET)。

不幸的是,结果集不包含 PK 字段……或者就此而言,如果我要破解模型,甚至可以充当 PK 的列。

任何人都可以想到我可以使用的黑客技巧:

  1. 在我的结果中添加一个字段,该字段插入一些自动递增值(充当 PK 候选者)
  2. 以某种方式将此字段设置为 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:

  1. Add a field to my result which inserts some auto-incrementing value (to act as a PK candidate)
  2. 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

心欲静而疯不止 2024-09-17 02:00:44

我不确定我是否理解为什么不能有一个可以充当主键的列。我刚刚对过滤到成员列表的一个多维数据集运行了类似的查询,并且每个列名称都包含成员名称。下面是一个例子:

提交:

 SELECT Measures.members ON ROWS,
 Customer.[CustomerIdKeyField].[UniqueCustomerId] ON COLUMNS
 FROM [Postage Prints]

返回:

(colum header)  [Measures].[MeasuresLevel].[MEMBER_CAPTION] [Customer].[CustomerIdKeyField].&[UniqueCustomerId]

(row) Measure1  9.6800000000000015

(row) Measure2  22

(row) Measure3  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:

 SELECT Measures.members ON ROWS,
 Customer.[CustomerIdKeyField].[UniqueCustomerId] ON COLUMNS
 FROM [Postage Prints]

Returned:

(colum header)  [Measures].[MeasuresLevel].[MEMBER_CAPTION] [Customer].[CustomerIdKeyField].&[UniqueCustomerId]

(row) Measure1  9.6800000000000015

(row) Measure2  22

(row) Measure3  1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文