private static IEnumerable <SqlDataRecord> ConvertToSqlDataRecord(IEnumerable <Movie> movies) { var sqlDataRecord = new SqlDataRecord(s_sqlMetaDataCreateMovies); foreach (var movie in movies) { sqlDataRecord.SetString(0, movie.Title); sqlDataRecord.SetString(1, GenreParser.ToString(movie.Genre)); sqlDataRecord.SetInt32(2, movie.Year); sqlDataRecord.SetString(3, movie.ImageUrl); yield return(sqlDataRecord); } }
public static DbCommand CreateCommandForGetMoviesByGenre(DbConnection dbConnection, Genre genre) { var dbCommand = dbConnection.CreateCommand(); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.CommandText = "dbo.GetMoviesByGenre"; AddReturnValueParameter(dbCommand); AddCommandParameter(dbCommand, "@Genre", ParameterDirection.Input, DbType.String, GenreParser.ToString(genre)); return(dbCommand); }