Jan,

I readed this sometime ago. I remember that the more important thing for
this is make some validations when put 1 item in the list. 1 very simple
Example:

public enum ItemType { Type1, Type2, Type3 }

    public class Container
    {
        private long id;
        private string name;
        private ItemType allowedType;
        private IList<Item> listItem;

        public long Id { get; set; }

        public string Name { get; set; }

        public ItemType AllowedType
        {
            get;
            set
            {
                if (listItem.Count == 0) { allowedType = value; }
            }
        }

        public IList<Item> ListItem { get { listItem.AsReadOnly(); } set; }

        public void AddItem(Item item) {
            if( item.ItemType.Equals( allowedType) ){
                listItem.Add(item);
            }
        }
    }

    public class Item
    {
        private long id;
        private string name;
        private ItemType itemType;

        public long Id { get; set; }

        public string Name { get; set; }

        public ItemType ItemType { get; set; }
    }

Something like this. What is the better way for do this??
Is better but this validation on Business Layer?


2008/11/1 Jan Limpens <[EMAIL PROTECTED]>

> Not necessary so. Who do you think this is the case?
>
> On Wed, Oct 29, 2008 at 10:38 AM, Symon Rottem <[EMAIL PROTECTED]> wrote:
> > Actually for a set you will need to use ImmutableSet<T>.
> >
> > Symon.
> >
> > On Wed, Oct 29, 2008 at 12:30 PM, Jan Limpens <[EMAIL PROTECTED]>
> wrote:
> >>
> >> I expose ISets as RadonlyCollection and use access strategy
> >> field.camalcase in the mapping, pointing to a private ISet
> >> Am 29.10.2008 um 09:25 schrieb Tiago Jesus:
> >>
> >> Thank you Gokhan,
> >>
> >> More 1 question, a fill days ago I readed that is important make the
> >> collections properties "Read only".
> >> I can't found again the article, how can I make a ISet read only?? Is It
> >> really necessary?
> >>
> >>
> >>
> >> 2008/10/29 Gökhan Altınören <[EMAIL PROTECTED]>
> >>>
> >>> Might also be helpful for the background:
> >>>
> >>>
> http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/06/12/mapping-collections-in-nhibernate-part-1.aspx
> >>>
> >>> On Wed, Oct 29, 2008 at 1:10 PM, Tiago Jesus <[EMAIL PROTECTED]>
> >>> wrote:
> >>>>
> >>>> Tkank you guys
> >>>>
> >>>> 2008/10/29 Ayende Rahien <[EMAIL PROTECTED]>
> >>>>>
> >>>>> http://www.hibernate.org/359.html#A9
> >>>>>
> >>>>> On Wed, Oct 29, 2008 at 12:22 PM, Tiago Jesus <[EMAIL PROTECTED]>
> >>>>> wrote:
> >>>>>>
> >>>>>> Hi guys,
> >>>>>>
> >>>>>> I Have 2 questions, witch I will be very happy with your answers.
> >>>>>>
> >>>>>> 1. What is better to use System.Collections.Generic.IList Or
> >>>>>> Iesi.Collections.ISet?
> >>>>>> 2. What is the different between  both?
> >>>>>>
> >>>>>> --
> >>>>>> ------------------------------------------
> >>>>>>   Tiago Oliveira de Jesus
> >>>>>>   [EMAIL PROTECTED]
> >>>>>>   Cel: 84 8824-0558
> >>>>>>
> >>>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>
> >>>>
> >>>>
> >>>> --
> >>>> ------------------------------------------
> >>>>   Tiago Oliveira de Jesus
> >>>>   [EMAIL PROTECTED]
> >>>>   Cel: 84 8824-0558
> >>>>
> >>>>
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >> --
> >> ------------------------------------------
> >>   Tiago Oliveira de Jesus
> >>   [EMAIL PROTECTED]
> >>   Cel: 84 8824-0558
> >>
> >>
> >>
> >>
> >> Jan Limpens
> >> [EMAIL PROTECTED]
> >>
> >>
> >>
> >>
> >
> >
> >
> > --
> > Symon Rottem
> > http://blog.symbiotic-development.com
> >
> > >
> >
>
>
>
> --
> Jan
> ___________________
> [EMAIL PROTECTED]
> www.limpens.com
> +55 (11) 3082-1087
> +55 (11) 3097-8339
>
> >
>


-- 
------------------------------------------
  Tiago Oliveira de Jesus
  [EMAIL PROTECTED]
  Cel: 84 8824-0558

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to