Issue migrating mapping from 3.9 to 4.3

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 years ago
Hello,

I have an issue upgrading my mappings from version 3.9 to 4.3.

I am trying to populate both Subgroup.Items and Item.Subgroup when loading from the database using a service class.

This is the code in 3.9
- MenuItem

    public string Name { get; set; }
    public int DisplayOrder { get; set; }
    public virtual TND_MenuSubgroup Subgroup { get; set; }
    public int TND_MenuSubgroupId { get; set; }


- MenuSubgroup

private ICollection<TND_MenuItem> _items;
    public string Name { get; set; }
    public int DisplayOrder { get; set; }
    public virtual ICollection<TND_MenuItem> Items
    {
      get { return _items ?? (_items = new List<TND_MenuItem>()); }
      protected set { _items = value; }
    }


- Mapping

this.HasRequired(pp => pp.Subgroup)
  .WithMany(p => p.Items)
  .HasForeignKey(pp => pp.TND_MenuSubgroupId);


I have created the domain objects in nopcommerce 4.3, but i have no idea how to upgrade the mapping, since i can't use the same syntax. It seems like the mapping is replaced by a Builder, but i can't really find any information on how to use them.

All help is appreciated :)
3 years ago
See if this helps
https://docs.nopcommerce.com/en/developer/plugins/plugin-with-data-access-4.30.html
3 years ago
Thanks for your reply.

This only loads the TND_MenuSubgroupId integer, but not the Subgroup object. It also does not load the ICollection<TND_MenuItem> collection.
3 years ago
Hello RikMaton
Entity framework is support one to many relationship, but fluentmigrator  doesn't support one to many relationship.
nopCommerce 4.30 is implemented with fluentmigrator.
Please look nopcommerce 4.30 default entities and mapping. ProductCategory mapping is the best example for you.
I hope you'll get your solution.
3 years ago
Thank you Sagar,

That definitely helped me understand why i'm having this problem.
I will take a look at the way the Product Category is implemented. I guess i'll be able to figure it out from there.

The whole caching system also seems to be quite different. Perhaps, you can also provide me with a good example to cache objects? I would like to cache a List<Object> if possible.
3 years ago
RikMaton wrote:

The whole caching system also seems to be quite different. Perhaps, you can also provide me with a good example to cache objects? I would like to cache a List<Object> if possible.

Please look Category service in GetAllCategories method, you'll get your solution on it.
3 years ago
Thank you for the quick response.

I have figured it out now, by looking at the CategoryService.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.