Esempio n. 1
0
        public Tag(ITaggable target, TagPrototype prototype)
        {
            if (prototype.TargetType != target.GetType())
                throw new ArgumentException("The given prototype is not compatible with the given target's type.",
                                            "prototype");

            Target = target;
            Prototype = prototype;
        }
Esempio n. 2
0
        public IList<Tag> GetByItem(ITaggable item)
        {
            var id = item.Id;
            var typeName = item.GetType().AssemblyQualifiedName;

            DetachedCriteria query =
                    DetachedCriteria.For(typeof(Tag), "t").
                    CreateCriteria("Prototype", "p", JoinType.InnerJoin);

            ICriteria criteriaQuery = query.GetExecutableCriteria(_session);

            criteriaQuery.Add(Restrictions.Eq("p.TargetTypeName", typeName));
            criteriaQuery.Add(Restrictions.Eq("t.TargetId", id));

            return criteriaQuery.List<Tag>();
        }