Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8854095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:48:25+00:00 2026-06-14T13:48:25+00:00

When should one use Fields from the CMS and when to use class properties

  • 0

When should one use Fields from the CMS and when to use class properties and database fields?

My scenario:
Created a product content part with fields usage (text) and price (double). Then I have created a contenttype product and added the part.

I could also have created a product record in models and added a product table. And a part with driver etc.
At first glance I dont see difference besides option 2 requiring programming.

However I did encounter a problem:
In option 2 I could use repository and create a lot of items programmatically.
In option 1 I could create product content items but was not able to fill in the fields of the product part (no errors, but fields remained empty)

So when to use option 1 and when option 2?
And is my problem with option 1 related to that option?

EDIT: Clarifiation of problem with option 1

I have created a productpart. To the productpart I have added the field price which is a decimal and I have added a field Usage of product which is a text field.

In the code I have the following:

        dynamic item = _cm.New("Product");
        item.TitlePart.Title = "Mijn dummy product";
        item.BodyPart.Text = "Some dummy text for this product";
        item.ProductPart.Price.Value = new decimal(20.5);
        item.ProductPart.Usage.Value = "Some dummy usage of this product";
        _cm.Create(item);

After running the code, the product is created with the correct title and body text, but Usage and Price come up emtpy.
I also tried it with the item.As<> method. But that does not compile to As since I have not created an object with that name.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T13:48:27+00:00Added an answer on June 14, 2026 at 1:48 pm

    Apparently the item has to be created first before accessing the contentpart and fields. At least it worked for me.

    Please verify if my analysis is correct. If so I will mark it an answer, as well as the answer of Bertrand.

    The code now looks like this:

        var item = _cm.New("Product");
        item.As<TitlePart>().Title = "Mijn dummy product";
        item.As<BodyPart>().Text = "Some dummy text for this product";
    
        //Create first before accessing the contentparts that are dynamic.
        _cm.Create(item);
    
        //And then access the product via dynamic object.
        dynamic dyn = item;
        item.ProductPart.Price.Value = new decimal(20.5);
        item.ProductPart.Usage.Value = "Some dummy usage of this product";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When should one use the f:viewAction or preRenderView event to initialize data for a
Possible Duplicate: When should one use final? When should Java programmers prefer to use
When exposing some code to D-Bus using Qt D-Bus bindings, when should one use
Are there any counterindications to fork under mod_perl2? Should one use another way to
What is a jagged array (in c#)? Any examples and when should one use
What tasks should one not use HBase for? My understanding is that HBase and
What fork, or combination of packages should one to use to make PyPy, Django
I've read that good programming practice claims that one should use a function if
I'm trying to understand whether and under what circs one should use Python classes
One should always use std::string over c-style strings( char * ) is advice that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.