简体   繁体   English

实体框架和MySql存储过程

[英]Entity Framework and MySql Stored Procedures

I am working with Entity Framework 4.0, VS 2010, MySql server database, and mysql-connector-net-6.4.4 for connection purpose. 我正在使用Entity Framework 4.0,VS 2010,MySql服务器数据库和mysql-connector-net-6.4.4进行连接。 It works fine, that said, it can generate Model classes, csdl, ssdl etc files well. 它工作正常,也就是说,它可以很好地生成Model类,csdl,ssdl等文件。 But, for stored procedures it doesn't work. 但是,对于存储过程,它不起作用。

Here is what happens.. 这是发生了什么..

Right clicked on an SP from Model Browser, select [Add Function Import]. 在模型浏览器中的SP上单击鼠标右键,选择[添加功能导入]。 This opened a dialog box Filled appropriate values like, Function Import Name, Stored Procedure Name Click on [Get Column Information]. 这将打开一个对话框,其中填充了适当的值,例如“函数导入名称”,“存储过程名称”。单击[获取列信息]。 This results into some Grid filled up at the bottom of this button. 结果是在此按钮底部填充了一些网格。 In the grid, there is a column named [EDM Type]. 在网格中,有一个名为[EDM类型]的列。 This column shows [Not supported] due to some unknown reason :( Now, clicked on [Create New Complex Type]. This goes OK, without Error Now, clicked on OK button After doing all above steps, there is no Complex Type created in the code however, which is the problem. 由于某些未知原因,此列显示[不支持] :(现在,单击[创建新的复杂类型]。这将正常,没有错误,现在,单击确定按钮。完成上述所有步骤之后,不会在代码,但是,这就是问题所在。

Can anyone please help? 谁能帮忙吗?

The generated Complex Type is in the Complex Types folder in the Model part of the Model Browser. 生成的Complex Type位于模型浏览器的模型部分的“ Complex Types文件夹中。

To access ti in code, use it as any other Entity 要使用代码访问ti,请与其他任何实体一起使用

MyComplexType ct = new MyComplexType();

And you can use it as a result type for your stored procedure: 您可以将其用作存储过程的结果类型:

List<MyComplexType> info = ctx.GetAllEmployees().ToList<MyComplexType>();

You must ensure that the GridView 's columns mappings match the Complex Type 's properties, or that the GridView 's property AutoGenerateColumns is set to true. 您必须确保GridView的列映射与Complex Type的属性匹配,或者将GridView的属性AutoGenerateColumns设置为true。

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

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