Developer forum

Forum » Development » Is code-first items broken in 8.4.1.5

Is code-first items broken in 8.4.1.5

Martin Nielsen
Reply

Hi DW,

I just downloaded a 8.4.1.5 and DefaultEmptyData8SQL, and wanted to play around with Code first items, but it doesn't seem to work.

I created a project with only the class below, and built it into my solution bin folder.

using Dynamicweb.Content.Items;
using Dynamicweb.Content.Items.Annotations;
namespace Attractionguide.Items
{
	public class Attraction : ItemEntry
	{
		[Group("Adresse")]
		[Name("Navn")]
		public string Name { get; set; }

		[Group("Adresse")]
		[Name("Vejnavn")]
		public string Road { get; set; }

		[Group("Adresse")]
		[Name("Postnummer")]
		public string Zipcode { get; set; }

		[Group("Adresse")]
		[Name("By")]
		public string City { get; set; }

		public override void Save()
		{
			base.Save();
		}

		public override void Delete()
		{
			base.Delete();
		}
	}
}

But my item doesn't show up in backend. I tried hitting refresh but that didn't help.

What am i missing?


Replies

 
Martin Nielsen
Reply

Okay, i got it working, apparently [Name("Attraktion")] is required on the class, so this code works

using Dynamicweb.Content.Items;
using Dynamicweb.Content.Items.Annotations;
namespace Attractionguide.Items
{
	[Name("Attraktion")]
	public class Attraction : ItemEntry
	{
		[Group("Adresse")]
		[Name("Navn")]
		public string Name { get; set; }

		[Group("Adresse")]
		[Name("Vejnavn")]
		public string Road { get; set; }

		[Group("Adresse")]
		[Name("Postnummer")]
		public string Zipcode { get; set; }

		[Group("Adresse")]
		[Name("By")]
		public string City { get; set; }

		public override void Save()
		{
			base.Save();
		}

		public override void Delete()
		{
			base.Delete();
		}
	}
}

Is it a bug or is in an error in the documentation? (Here: http://developer.dynamicweb-cms.com/documentation/for-developers/item-based-structure/getting-started.aspx)

 

You must be logged in to post in the forum