More explanation about [Ignore] attribute

Vote:
 

Hi all,

as [Ignore] attribute's comment states - "When applied to the property of a model type, specifies that the property should be ignored" - and it did exactly what I needed - hid the property input field from the UI in admin panel. 

However does that mean that this attribute will destroy property value of previously created pages with that property?

What I exactly want to do is to introduce new property on a page type and to use it instead of old one, but I can't remove old one, but want to hide it so admins wouldn't use it.

Cheers!

#208335
Oct 22, 2019 9:58
Vote:
 

Episerver will not delete your data. You may safely add the [ignore]-attribute, or even completely remove the property definition from your code. As long as the property contains data, it will not be completely deleted.

You may also use:

[ScaffoldColumn(false)]



See http://www.jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-properties/how-to-hide-a-property-in-episerver-cms-and-how-to-make-a-property-readonly

#208350
Edited, Oct 22, 2019 13:11
Tim Schmelter - Nov 23, 2021 9:09
The linked page doesn't explain what happens with properties that have the [Ignore] attribute. Are they saved at all in the database? What does it mean that they are "ignored"?
Tomas Hensrud Gulla - Nov 23, 2021 9:27
I think Darren answered this below.

If the property is ignored, any value previously stored in the database will not be removed. If the property is hidden, any new data is probably not getting stored there.
Tim Schmelter - Nov 23, 2021 9:37
Thanks. But what if the property is new and there is no data in the database. Will it be saved in DB or not?
Tomas Hensrud Gulla - Nov 23, 2021 9:53
Well, that's easy to test.

I'm adding two new properties to an existing pagetype.

[Ignore]
public virtual string TempProperty1 { get; set; }

[ScaffoldColumn(false)]
public virtual string TempProperty2 { get; set; }

Starting the site, making sure the properties are not visible, and then checking the database.
SELECT *
FROM [tblPropertyDefinition]
WHERE [Name] IN ('TempProperty1', 'TempProperty2')

This will return only one line, and that's the definition of TempProperty2

[Ignore] will completely ignore the property and [ScaffoldColumn(false)] will just not do the scaffolding, i.e. the process of creating the input field for the editor.
Tim Schmelter - Nov 23, 2021 10:14
Thanks for the confirmation
Vote:
 

Hi Fugio,

"does that mean that this attribute will destroy property value of previously created pages"

No, [Ignore] attribute will not destroy previously saved property values. It will hide the Property.

Here is a good reference http://www.jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-properties/how-to-hide-a-property-in-episerver-cms-and-how-to-make-a-property-readonly

#208351
Edited, Oct 22, 2019 13:15
- Oct 22, 2019 13:17
Haha @tomas you beat me by 3mins!
- Oct 22, 2019 13:17
Haha, type faster next time! :-)
- Oct 22, 2019 13:20
I was on my phone!!
Tomas Hensrud Gulla - Nov 23, 2021 9:24
Ha ha! Excuses, excuses... :-D
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.