I added this code below:
public partial class Form1 : Form
{
TestAdonetEntity2Entities entityContext;
public Form1()
{
InitializeComponent();
entityContext = new TestAdonetEntity2Entities();
}
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = entityContext.SelectMyCustomer();
}
}
But this code will cause an error:
public global::System.Data.Objects.ObjectResult<MyCustomer> SelectMyCustomer()
{
return base.ExecuteFunction<MyCustomer>("SelectMyCustomer");
}
The error is:
An error occurred while executing the command definition. See the inner exception for details.
My stored procedure...:
ALTER procedure [dbo].[proc_MyCustomer]
as
begin
select * from dbo.MyStuffs
end
My Columns: CustomerID PK ink
Name nvarchar(50)
SurName nvarchar(50)
Here's an MSDN article about using sprocs in Entity Framework.
And another one.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.