Microsoft Office Tutorials and References
In Depth Information
NationalIDNumber is an nvarchar(15) data type. Make sure you rename the existing return parameter
identifier1 to BusinessEntityID . perform these steps for all the columns that you’d like to retrieve. repeat the
steps for returnParameter under the ReadList method.
Columns chosen in this example are BusinessentityiD {int}, nationaliDnumber {nvarchar(15)}, LoginiD
{nvarchar(256)}, Jobtitle {nvarchar(50)}, BirthDate {datetime}, Maritalstatus {nchar(1)}, Gender {nchar(1)}, hireDate
{datetime}, salariedFlag {Flag(bit)}, vacationhours {smallint}, sickLeavehours {smallint}, CurrentFlag {Flag(bit)} and
ModifiedDate {datetime}.
Note
9.
switch to solution explorer, open the entity1.cs file, and remove the lines of code for the
Message property declaration.
10.
Modify the public properties under Entity1 as shown in Listing 4-4.
Listing 4-4. Properties in the Entity1 Class
public Int32 BusinessEntityID { get; set; }
public string NationalIDNumber { get; set; }
public string LoginID { get; set; }
public string JobTitle { get; set; }
public DateTime BirthDate { get; set; }
public char MaritalStatus { get; set; }
public char Gender { get; set; }
public DateTime HireDate { get; set; }
public bool SalariedFlag { get; set; }
public Int16 VacationHours { get; set; }
public Int16 SickLeaveHours { get; set; }
public bool CurrentFlag { get; set; }
public DateTime ModifiedDate { get; set; }
11.
in the entity1service.cs file, declare the namespace System.Data.SqlClient :
using System.Data.SqlClient;
12.
Copy the code in Listing 4-5 for the ReadList method into the entity1service.cs file.
Listing 4-5. The ReadList Method
List<Entity1> entityList = new List<Entity1>();
using (SqlConnection conn = new SqlConnection(
"Data Source=localhost; Integrated Security=SSPI; Initial
Catalog=AdventureWorks2012"))
{
conn.Open();
using (SqlCommand cmd = new SqlCommand("uspGetEmployees", conn))
{
cmd.CommandType = System.Data.CommandType.StoredProcedure;
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
 
 
Search JabSto ::




Custom Search