In order to read data from the DB, I have done the following:
1) Added under Core.Domain.SDSharp folder one a TaxRateByCity.cs file
using Nop.Core;
namespace SDSharp.Core.Domain.Tax
{
public partial class TaxRateByCity : BaseEntity
{
public virtual string State { get; set; }
public virtual string City { get; set; }
public virtual float Rate { get; set; }
}
}
2) Added reference to SDSharp.Core.Domain.Tax on the SDSharpServices.cs file
using SDSharp.Core.Domain.Tax;
3) Added a variable for the Service
private readonly IRepository<TaxRateByCity> _taxratebycityRepository;
4) On Constructor I pass a reference of the Services:
public SDSharpServicecs(IRepository<TaxRateByCity> taxratebycityRepository)
{
this._taxratebycityRepository = taxratebycityRepository;
}
=======================
When I run the Shopping Cart, the following code is executed:
public virtual decimal GetTaxRateByCity(string state, string city)
{
var query = from c in _taxratebycityRepository.Table
where (c.City == city) && (c.State == state)
select c.Rate;
decimal rate = Convert.ToDecimal(query.FirstOrDefault());
return rate;
}
ERROR:
The entity type TaxRateByCity is not part of the model for the current context.
Any idea what am I missing ??
How does the Domain Model get attached to the actual Table?
Notice i do NOT have a PK on that Domain, is this a problem?