Writing the SqlCommandModel class
In this section, we write a simple class that models a SQL command. Follow these steps:
- Open the
SqlCommandModelclass, define the class as public, and add theSystem.Datanamespace. - Now, add the following three properties:
public string CommandText { get; set; } public CommandType CommandType { get; set; } public SqlCommandParameterModel[] CommandParameters { Â Â Â Â get; set; }
The CommandText property holds our SQL command. This may be the name of a stored procedure or a SQL statement. The CommandType property determines whether the command is a Text command or a StoredProcedure command, while the CommandParameters property contains an array of SQL command parameters.
Now that we have written SqlCommandModel, let's write the SqlCommandParameterModel class.