Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Im using Umbraco 12.
Back in v8 i could do the things like this
[TableName("ExypnosSalesContent")] [PrimaryKey("Id", AutoIncrement = true)] [ExplicitColumns] public class ExypnosSalesContent { [PrimaryKeyColumn(AutoIncrement = true, IdentitySeed = 1)] [Column("id")] public int Id { get; set; } [Column("productId")] public int ProductId { get; set; } [Column("variantKey")] public Guid VariantKey { get; set; } public string? ProductName { get { IPublishedContent product = Umbraco.Content(this.ProductId); return product.Name; } } }
However in v12 I cant figure out how to do this.
This is what I have
public class ExypnosSalesContentAddTable : MigrationBase { private readonly IScopeProvider _scopeProvider; private readonly IPublishedContentQuery _publishedContentQuery; public ExypnosSalesContentAddTable(IMigrationContext context, IScopeProvider scopeProvider, IPublishedContentQuery publishedContentQuery) : base(context) { _scopeProvider = scopeProvider; _publishedContentQuery = publishedContentQuery; } [TableName("ExypnosSalesContent")] [PrimaryKey("Id", AutoIncrement = true)] [ExplicitColumns] public class ExypnosSalesContent { [PrimaryKeyColumn(AutoIncrement = true, IdentitySeed = 1)] [Column("id")] public int Id { get; set; } [Column("productId")] public int ProductId { get; set; } public string? ProductName { get { IPublishedContent product = _publishedContentQuery.Content(this.ProductId); return product.Name; } } } }
_PublisherContentQuery is not null here
error
CS0120 object referance is required for non-static field, methos or property
How do I do this in v12
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
connecting content in my models
Im using Umbraco 12.
Back in v8 i could do the things like this
However in v12 I cant figure out how to do this.
This is what I have
_PublisherContentQuery is not null here
error
CS0120 object referance is required for non-static field, methos or property
How do I do this in v12
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.