Fluent API Example
Can someone post some fluent api examples from the webinar for me? Specifically the one that Ivan showed where a blog is created and then post are added to it within the same scope. There was a piece of code that added a description to the blog after it had been created and a child post was created.. We are curious to see this code again...
Thanks
Hi Drew Greenwell,
Below is a sample code. I believe that the webinar will be available on tv.telerik.com or/and sitefinitywatch.com so you will be able to take a look at it again.
using
Telerik.Sitefinity;
using
Telerik.Sitefinity.GenericContent.Model;
..
...
var BlogId = Guid.Empty;
App.WorkWith()
.Blog()
.CreateNew()
.Do(b =>
b.Title =
"NewBlog"
;
b.Description =
"My 4.0 Blog"
;
BlogId = b.Id;
)
.SaveChanges();
NewBlog
").Get().First(); NewBlog
) .BlogPost().CreateNew().Do( b => b.Owner = myBlog.Id) and finally commit the changes.Thanks for the response Ivan. I was wondering about the code where you created a blog then created posts for it all in one statement..
it was something like
App.WorksWith()
.Blog()
.CreateNew()
.Do(b=>
b.Title =
"A new Blog"
;
)
.BlogPost().CreateNew()
.Do(bp => bp.Title =
"A new Blog Post"
;)
.Done()
//b shouldnt exist here so I think Im missing a step you took to reaccess the blog object you created
.Do(b.Description =
"Oops forgot to add a description"
)
.SaveChanges(
);
Hi Drew Greenwell,
Yes, some minor corrections are needed:
App.WorksWith()
.Blog()
.CreateNew()
.Do(b =>
b.Title =
"A new Blog"
;
)
.BlogPost()
.CreateNew()
.Do(bp => bp.Title =
"A new Blog Post"
;)
.Done()
.Do( b => b.Description =
"Oops forgot to add a description"
)
.SaveChanges();
I figured that was it, Thanks!