I have an error:
(Cannot implicitly convert type 'shenoy webapi.Models.PartIndex' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?) shenoywebapi D:\shenoystudio\shenoywebapi\Controllers\RateController.cs 69 Active)
[Route("api/Rate/getproductrate")]
public IEnumerable<Rate> GetProductRate()
{
var list = new List<Rate>();
var dsRate = SqlHelper.ExecuteDataset(AppDatabaseConnection, CommandType.StoredProcedure, 0, "GetProductRates");
if (dsRate.Tables[0].Rows.Count > 0)
{
foreach (DataRow row in dsRate.Tables[0].Rows)
{
list.Add(new Rate
{
Id = Convert.ToInt64(row[0]),
SerialNumber = row[1].ToString(),
ProductName = row[2].ToString(),
Unit = row[3].ToString(),
PartIndex = new PartIndex { Series = row[4].ToString() },
});
}
}
return list;
}
This is my model:
namespace shenoywebapi.Models
{
public class Rate
{
public long Id { get; set; }
public DateTime wefDate { get; set; }
public string SerialNumber { get; set; }
public string ProductName { get; set; }
public string Unit { get; set; }
public long Rates { get; set; }
public IEnumerable<PartIndex> PartIndex { get; set; }
}
}
Severity Code Description Project File Line Suppression State Error CS0266 Cannot implicitly convert type 'shenoywebapi.Models.PartIndex' to 'System.Collections.Generic.IEnumerable'. An explicit conversion exists (are you missing a cast?) shenoywebapi D:\shenoystudio\shenoywebapi\Controllers\RateController.cs 69 Active