AdFactum ObjectMapper .NET Blog

Official blog of the AdFactum ObjectMapper .NET

Attribute: [GroupBy]

Posted by Gerhard Stephan on March 7th, 2008

The [GroupBy] attribute can be used to group properties by there value. This property can only be used in projection classes.

    /// <summary>

    /// Groups the time entries by their project id

    /// </summary>

    public class TimeEntryGrouping


        private DateTime minDate;

        private string project;


        /// <summary>

        /// Gets or sets the min date.

        /// </summary>

        /// <value>The first date.</value>

        [ProjectOntoProperty(typeof(TimeEntry), "StartDate")]


        public DateTime MinDate


            get { return minDate; }

            set { minDate = value; }



        /// <summary>

        /// Gets or sets the project.

        /// </summary>

        /// <value>The project.</value>

        [ProjectOntoProperty(typeof(TimeEntry), "ProjectId")]


        public string Project


            get { return project; }

            set { project = value;  }




Select the grouping:


                List<TimeEntryGrouping> result =

                    new List<TimeEntryGrouping>(

                        new ListAdapter<TimeEntryGrouping>(



Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>