0
Reply

command.ReadList<Product>(ReadProduct) is absolute

Cassie Mod

Cassie Mod

Jun 9 2016 11:11 AM
302
HI I've got the following method. It gives the error "Command.ReadList<Product>(ReadProduct) is absolute, use dapper instead. How can I fix this ??
 
here is my method
 
 
  1. public static List<Product> LoadProducts(SqlConnection connection, SqlTransaction transaction, HostedType? HostedType, Platforms? Platform)  
  2.       {  
  3.           using (var command = connection.CreateCommand())  
  4.           {  
  5.               command.Transaction = transaction;  
  6.               command.CommandText = "SELECT " + _fields + " FROM Products INNER JOIN ProductGroups " +  
  7.                                     "ON Products.ProductGroupId = ProductGroups.GroupId " +  
  8.                                     "WHERE 1=1 ";  
  9.               if (HostedType.HasValue)  
  10.               {  
  11.                   command.CommandText += "AND Products.HostedTypeId = @HostedTypeId OR Products.HostedTypeId IS NULL ";  
  12.                   command.Parameters.Add("@HostedTypeId", SqlDbType.Int).Value = HostedType.Value;  
  13.               }  
  14.               if (Platform.HasValue)  
  15.               {  
  16.                   command.CommandText += "And Products.PlatformId = @PlatformId OR Products.PlatformId IS NULL";  
  17.                   command.Parameters.Add("@PlatformId", SqlDbType.Int).Value = Platform.Value;  
  18.               }  
  19.               return command.ReadList<Product>(ReadProduct); // this part is abolsute , how can I fix this ? now it it crashing in my unit test  
  20.           }  
  21.       }