Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Jun 9, 2012
(1 votes)

Community Attribute Builder final

If you are working with Relate+ platform most probably you are using entities attributes to attach some additional info to particular entity type. This is a great way to extend built-in functionality but however involved a bit of manual work:

  1. You have to define attribute for each of the entity in Relate+ administrative UI (which honestly speaking could be made more user friendly).
  2. You have to refer to the attribute via stringly-typed interface.


Latter for me is most embarrassing.


instance.SetAttributeValue("attributeName", attributeValue);


This approach could give you few real scenarios where such is unacceptable:

  1. When you will margin for a grammar error when typing attribute name – that could be discovered only during runtime.
  2. You cannot use static code analysis tools. Like to search for all attribute usages.
  3. You cannot use some of the refactoring tools –> like rename attribute name.
  4. You can easily change type of the attribute and forget about code that uses that, effect –> runtime error(s).
  5. Use cannot leverage all the power of Visual Studio (for instance to provide Intellisense over available attributes)


So therefore I created package that should relief tasks with Community entity’s attributes – Community Attribute Builder.

There were already some posts on this topic here, here and there. Latest version (1.0) is out and this is just a summary of what’s supported.


1. Describe community entity’s attributes in code. Those attributes defined in metadata class are synced during application start-up and added to the target entity:


[CommunityEntity(TargetType = typeof(IUser))]
public class SampleAttributeMetadata
    public virtual IList<SampleType> SampleAttribute { get; set; }


2. Limit scanning of the assemblies:


    <section name="entityAttributeBuilder" type="Geta.Community.EntityAttributeBuilder.EntityAttributeBuilderConfiguration, Geta.Community.EntityAttributeBuilder" />

      <add assembly="EntityAttributes" />
      <remove assembly="RemoveAssembly" />


3. You can set or get entity’s attribute value(s) using strongly-typed interface.


var metadata = instance.AsAttributeExtendable<SampleAttributeMetadata>();
metadata.SampleAttribute = null;


4. Support for strongly typed queries


var query = new UserQuery();
var qmetadata = query.AsMetadataQuery<SampleAttributeMetadata>();
qmetadata[m => m.SampleAttribute] = new StringCriterion { Value = "the attribute value" };


5. Added support for IList<T> type attributes. You can assign via local variable assignment and modification or using line modifications.


var entity = instance.AsAttributeExtendable<SampleAttributeMetadata>();

// getter
var collection = entity.SampleAttribute;
collection.Add(new SampleType(100));
// setter
entity.SampleAttribute = collection;


or you can use more convenient syntax:


var entity = instance.AsAttributeExtendable<SampleAttributeMetadata>();
entity.SampleAttribute.Add(new SampleType(100));



Rename, deletion and content migration for the community entity attributes need to me done manually.

Can be found here (or search by “community” in NuGet package manager).


I somebody is really curious how to implement interfaces like these – strongly-typed interface over stringly-typed one, some basics could be found here.

Source could be found in GitHub.



Hope this helps!

Jun 09, 2012


Jun 13, 2012 12:41 PM

Very useful, nice work! Now we got PTB and CAB :)

Please login to comment.
Latest blogs
Optimizely DXP - Leader in Forrester Wave Q4 2023

There are many reasons why its nominated as leader including below but not limited to: Developers friendly - devs and architect love to implement i...

Yagnik Jadav | Dec 11, 2023 | Syndicated blog

Live on Optimizely CMS 12 and .NET 8

"Better late than never" is a fitting saying here. We've finally gotten around to updating the website to Optimizely CMS 12 and .NET 8!

Allan Thraen | Dec 10, 2023 | Syndicated blog

Date property editor

The Optimizely CMS has built-in DateTime property. When editing, the Editor selects both the date and the time. Sometimes we would like to configur...

Grzegorz Wiecheć | Dec 9, 2023 | Syndicated blog

Update related content

In this article, I will show simple code that allow to replace linked content with other content selected by the Editor. When deleting content whos...

Grzegorz Wiecheć | Dec 8, 2023 | Syndicated blog

Getting Started with Optimizely SaaS Core and Next.js Integration: Content Areas and Blocks

The blog guide elaborates on improving content rendering by exploring content areas and blocks within the Optimizely CMS. It walks through setting ...

Francisco Quintanilla | Dec 8, 2023 | Syndicated blog

Maximize performance by uploading your external data to Optimizely Graph

Learn to integrate external data into Optimizely Graph for improved performance, covering data preparation, synchronization, and effective querying.

Surjit Bharath | Dec 6, 2023 | Syndicated blog