Fluent->Anon Type

Posted by Community Admin on 04-Aug-2018 16:06

Fluent->Anon Type

All Replies

Posted by Community Admin on 08-Sep-2011 00:00

Is it possible in the Fluent interface to define a custom type?

This is what I normally do, but I'm wondering if it can be done inline without needing to manipulate the collection a second time

Posted by Community Admin on 13-Sep-2011 00:00

Hi Steve,

Can you please clarify the question? I think that I am not able to understand fully what you want to achieve.

Kind regards,
Radoslav Georgiev
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

Posted by Community Admin on 13-Sep-2011 00:00

Something like

var (dyanmic?) person = App.WorkWith().
                                                  ....
                                                  .Get()
                                                  .Select(x => new
                                                      Name = x.FullName,
                                                      Address = x.Address
                                                       );

...so the "person" comes back as a dynamic or anon type in the Fluent query without needing to re-flatten it

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

Hi Steve,

I think that we already support this. Isn't the below what you want to do:

var newsQuery = from nI in App.WorkWith().NewsItems().Get()
                where nI.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live
                select new Title = nI.GetString("Title") ;

The peculiarity here is the LString type, to be able to serve those properties you need to get their string representation for the current culture.

Best wishes,
Radoslav Georgiev
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

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

Yeah okay so I guess it was more of a Linq question really...

So the from <x> in <y> syntax is the only way to do it

Thanks! :)

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

Hi Steve,

Well, no. What ever is supported on IQuerieable, see sample below:

var newsQuery = App.WorkWith()
                   .NewsItems()
                   .Where(nI=> nI.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get()
                   .Select(nI => new Title = nI.GetString("Title"), nI.Id);


Greetings,
Radoslav Georgiev
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

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

THAT was the syntax I was looking for thanks much!

This thread is closed