What am I not understanding about the fluent api?

Posted by Community Admin on 04-Aug-2018 14:36

What am I not understanding about the fluent api?

All Replies

Posted by Community Admin on 16-Dec-2011 00:00

Hi guys, 

I have set up a widget for the backend of my Sitefinity site that has three textboxes and a button. The goal is to create a new column in the database:

    protected void btnAddClick(object sender, EventArgs e)
   

       
Type TelerikType = Type.GetType(txtTelType.Text);
       
Type ColumnType = Type.GetType(txtColType.Text);
       
string error = "";
       
if (TelerikType == null)
       

            error
= "Telerik Type is invalid";
       

       
if (ColumnType == null)
       

            error
= "Column Type is invalid";
       

       
if (error.Length == 0)
       

           
App.WorkWith()
             
.DynamicData()
             
.Type(TelerikType)
             
.Field()
                   
.TryCreateNew(txtName.Text, ColumnType)
                   
.SaveChanges(true);
            error
= "Added column successfully";
            txtColType
.Text = txtName.Text = txtTelType.Text = "";
       

        literalErrorText
.Text = string.Format(literalErrorText.Text, error);

   

I am having two problems:

  1. When I enter Telerik.Sitefinity.Pages.Model.PageNode into the textbox, Type.GetType(txtTelType.Text) is returning null.

  2. If I replace that portion with typeof(PageNode) I get "Specified type 'Telerik.Sitefinity.Pages.Model.PageNode' is not a dynamic type."

I'm hoping somebody might have some insight as to why these things wouldn't work correctly, or possibly a better way to approach this issue? For reference, my goal (at least for now) is to add a dynamic column that references PageNode so that I can specify a ShowInLeftNavigation boolean and a ShowInRightNavigation boolean. Thank you for any help you can provide.

Posted by Community Admin on 16-Dec-2011 00:00

I figured out what I was doing wrong with the TelerikType, I needed to qualify it with an assembly name, so I changed it thusly: 

                      var assembly = typeof(Telerik.Sitefinity.News.Model.NewsItem).Assembly;
            Type TelerikType = Type.GetType(txtTelType.Text + ", " + assembly.ToString());
I would still appreciate a better approach if anybody has any ideas, and I would still appreciate help on the second question, which is 
to say, why isn't pagenode dynamic? Where do I add a column to pages, and how do I access it after I do that? I'm sorry if this is clear
in the documentation, I can't seem to find the right information in there.
            

Posted by Community Admin on 19-Dec-2011 00:00

I guess what I'm really after here is why is PageNode not a dynamic type, and what dynamic type should I use here to attach a column to pages.

Posted by Community Admin on 21-Dec-2011 00:00

Hi Jeff,

 The type you need to use is PageData, not PageNode. Can you check the following thread, that describes the same problem and provides solution:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/bugs-issues/custom-fields-for-pages.aspx 
If you have any further questions, please do not hesitate to write back.

Kind regards,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed