public
int
callMySproc() { DbCommand command =
this
.CreateStoreCommand(
"MySproc"
,
CommandType.StoredProcedure);
result;
using (
.Connection.CreateConnectionScope()) { result
=
command.ExecuteNonQuery(); }
return
result; }
using
(var context =
new
SchoolEntities()) {
string
providerString = @"Data Source=.;Initial
Catalog=School;Integrated Security=True";
(var
conn =
SqlConnection(providerString)) { var
cmd =
conn.CreateCommand(); cmd.CommandType
System.Data.CommandType.StoredProcedure; cmd.CommandText
"GetStudentGrades"
; cmd.Parameters.AddWithValue(
"StudentID"
2); conn.Open(); var
reader =
cmd.ExecuteReader( System.Data.CommandBehavior.CloseConnection); var
students = context.Translate<Person>( reader,
"People"
MergeOption.AppendOnly).ToList(); reader.NextResult(); context.Translate<StudentGrade>(reader,
"StudentGrades"
, MergeOption.AppendOnly) .ToList();
foreach
(var student
in
students) {
(var grade
student.StudentGrades) { Console.WriteLine(grade.Grade); } } } }
context.ExecuteStoreCommand(
"EXEC StoredProcedure1 @param1, @param2 OUT"
storeParams);
<
Function
Name
"StudentInfo"
>
Parameter
"PersonID"
Type
"Edm.Int32"
/>
ReturnType
CollectionType
RowType
Property
"FirstName"
"Edm.String"
"Grade"
"Edm.Decimal"
</
DefiningExpression
select sg.Person.FirstName, sg.Grade
from SchoolEntities.StudentGrades as sg
where sg.Person.PersonID == PersonID