i´m try to use similliar process to entry foreign entity in my 4.60 plugin like in Linq/Entity framework >> "timeRecord.Tag.ValueForExample" where "Tag" is foreign table.
Foreign entity "Tag" is null everytime.
namespace Nop.Plugin.NCH.Domain.TimeRecord
{
public class TimeRecord : BaseEntity
{
public new Int64 Id { get; set; }
public Int64 TagId { get; set; }
public decimal Rssi { get; set; }
virtual public Tag Tag { get; set; }
}
}
// builder
namespace Nop.Plugin.NCH.Domain.TimeRecord.Mapping
{
public class TimeRecordBuilder : NopEntityBuilder<TimeRecord>
{
public override void MapEntity(CreateTableExpressionBuilder table)
{
table.WithColumn(nameof(TimeRecord.Id)).AsInt64().PrimaryKey()
.WithColumn(nameof(TimeRecord.TagId)).AsInt64().ForeignKey<Tag>("Tag","Id")
}
}
}
I hope is not only possible way load Tag by Id through _tagService and fill entity TimeRecord :-)
Thank you for help.