Fluent API example in VB
Hi,
Hi Peter,
It would be easier if you provide us the Fluent API code that you use. There are many samples and scenarios and it is not clear which one you are refering to.
All the best,
Ivan Dimitrov
the Telerik team
Hi Ivan
using (var fluent = App.WorkWith())
// create 10 content items
for (int i = 0; i <
10
; i++)
fluent.ContentItem()
.CreateNew()
.Do(ci =>
ci.Title = "Content item " + i.ToString();
ci.Author = "Ivan";
);
// create 20 events
for (int i = 0; i <
20
; i++)
fluent.Event()
.CreateNew()
.Do(ev =>
ev.Title = "Event " + i.ToString();
ev.EventStart = DateTime.Now;
);
Hello Peter,
We used the converter from converter.telerik.com, and here is the resulted code:
Using fluent = App.WorkWith()
' create 10 content items
For
i
As
Integer
= 0
To
9
fluent.ContentItem().CreateNew().[
Do
](
Function
(ci)
Do
ci.Title =
"Content item "
+ i.ToString()
ci.Author =
"Ivan"
End
Function
)
Next
' create 20 events
For
i
As
Integer
= 0
To
19
fluent.[
Event
]().CreateNew().[
Do
](
Function
(ev)
Do
ev.Title =
"Event "
+ i.ToString()
ev.EventStart = DateTime.Now
End
Function
)
Next
End
Using
'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================
I'm using VB.
I am trying to locate an ALBUM by Album name with the Fluent API.
It seems NO MATTER what I try, the following will blow up with an "Index out of range" problem... It is something with the WHERE.
App.WorkWith.Albums.Where(Function(a) a.Title.Value.ToString = "AlbumName").Get.First
I can get a list of albums ok...
I can get the FIRST album ok (by just pulling pulling the first off the stack)...
But, when I try to filter with the WHERE, it will ALWAYS blow up.
Now... If I do the following:
App.WorkWith.Albums.Get.ToList.Where(Function(a) a.Title.Value.ToString = "AlbumName").Get.FirstOrDefault
This DOES work.
Notice how I did the WHERE after I cut my ties to the Fluent API LINQ implementation (i.e. after the ToList).
So, does that tell me that there is a serious bug in the VB Fluent API LINQ implementation???
I see this very simile code in C# examples all over the place and nobody is complaining, but I can't do a very simple WHERE with the VB implementation.
What is going on here??
Hi Shawn Krivjansky,
As we have already discussed this issue in a support ticket I am going to quickly summarize the problem.
This is a problem of the Sitefinity OQL parser and should be resolved with the 2011 Q1 release, when we change the OQL parser to the Telerik OpenAccess built in one. There is a PITS item which you can track for status updates on this issue.
Kind regards,
Radoslav Georgiev
the Telerik team
Just wanted to give an update after 8 months...
I ran into this same problem again... Still not fixed. Still "IN PROGRESS" in the PITS system.
I'm not holding my breath.
Guess I'll just continue to hit this same problem everytime I try to do something.
Hi Shawn Krivjansky,
We have replaced the Sitefinity OQL parser in 4.1 and these types of queries do work. Please consider bellow example:
Dim
album = App.WorkWith().Albums().Where(
Function
(a) a.Title.Equals(
"Opportunities"
)).
Get
.FirstOrDefault
Dim
album = App.WorkWith().Albums().Where(
Function
(a) a.Title.Equals(
"Opportunities"
)).
Get
.FirstOrDefault
Dim
images = App.WorkWith.Images.Publihed.Where(
Function
(img) img.Parent.Id = album.Id).
Get