简体   繁体   English

C#报表向导和实体框架

[英]C# Report Wizard and Entity Framework

This is probably quite simple, but I just don't know how to do this... 这可能很简单,但是我只是不知道该怎么做...

I have a reasonable complex SQL Server database containing multiple schema's for data and a generic view to provide information over all those views. 我有一个合理的,复杂的SQL Server数据库,其中包含用于数据的多个架构和一个可在所有这些视图上提供信息的通用视图。 (Basically, it lists all extended properties of all schema's.) This setup cannot be changed since every schema is specific for one single office, while the whole database contains all company data. (基本上,它列出了所有架构的所有扩展属性。)由于每种架构都专用于一个办公室,而整个数据库包含所有公司数据,因此无法更改此设置。

I'm using the Entity framework to connect to all the data inside those schema's and to link them together. 我正在使用Entity框架连接到那些架构内部的所有数据,并将它们链接在一起。 This makes it easy to retrieve whatever data I need. 这样可以轻松检索我需要的任何数据。 Thus, the configuration file contains one connection string for the entity framework. 因此,配置文件包含一个用于实体框架的连接字符串。

I'm also using a single report to create a matrix overview of all the schema data. 我还使用一个报告来创建所有模式数据的矩阵概述。 This is a matrix based on a view with three fields: Schemaname, field and value. 这是基于具有三个字段的视图的矩阵:模式名称,字段和值。 The report puts the schemaname vertical as row-header, fieldname horizontal as column header and the value in the cells. 该报告将模式名称垂直作为行标题,将字段名称水平作为列标题,并将值存储在单元格中。 But this report uses it's own connection string in the configuration. 但是此报告在配置中使用它自己的连接字符串。

I need both to share the same connection! 我需要两个共享相同的连接! Or at least the same connection string in the configuration. 或至少在配置中使用相同的连接字符串。 What options do I have? 我有什么选择?

It's trivial to retrieve the DB connectionstring from the EF connectionstring. 从EF连接字符串中检索数据库连接字符串很简单。 Use EntityConnectionStringBuilder to parse it. 使用EntityConnectionStringBuilder对其进行解析。 You can also supply a connection to an EF context . 您还可以提供与EF上下文的连接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM