1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Fluent->Anon Type

Fluent->Anon Type

7 posts, 1 answered
  1. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    08 Sep 2011
    Link to this post
    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
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Sep 2011
    Link to this post
    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
  3. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    13 Sep 2011
    Link to this post
    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
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Sep 2011
    Link to this post
    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
  5. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    16 Sep 2011
    Link to this post
    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! :)
  6. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    16 Sep 2011
    Link to this post
    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
    Answered
  7. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    16 Sep 2011
    Link to this post
    THAT was the syntax I was looking for thanks much!
7 posts, 1 answered