<commit_before>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NHibernateExperiments.DTOs
{
    public class Entity
    {
        IReadOnlyCollection<EntityItem> readonlyItems;
        public Entity()
        {
            InternalItems = new HashSet<EntityItem>();
            readonlyItems = null;
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        protected virtual ISet<EntityItem> InternalItems { get; set; }

        //public virtual IReadOnlyCollection<EntityItem> Items
        //{
        //    get
        //    {
        //        if (readonlyItems == null || readonlyItems.Count != InternalItems.Count)
        //        {
        //            readonlyItems = new ReadOnlyCollection<EntityItem>(InternalItems.ToList());
        //        }
        //        return readonlyItems;
        //    }

        //}

        public virtual bool AddItem(EntityItem item)
        {
            item.Parent = this;
            return InternalItems.Add(item);
        }

        public virtual bool RemoveItem(EntityItem item)
        {
            item.Parent = null;
            return InternalItems.Remove(item);
        }
    }

    public class EntityItem : IEquatable<EntityItem>
    {
        public virtual Guid Id { get; set; }

        public virtual string Description { get; set; }

        public virtual Entity Parent { get; set; }

        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return false;
            }

            // If parameter cannot be cast to Point return false.
            EntityItem p = obj as EntityItem;
            if ((System.Object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (Id == p.Id);
        }

        public virtual bool Equals(EntityItem p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (Id == p.Id);
        }

        public override int GetHashCode()
        {
            return 23 ^ Id.GetHashCode();
        }
    }
}
<commit_msg>Nhibernate tests<commit_after>﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NHibernateExperiments.DTOs
{
    public interface IQueryableItems
    {
        ISet<EntityItem> InternalItems { get; set; }
    }

    public class Entity : IQueryableItems
    {
        IReadOnlyCollection<EntityItem> readonlyItems;
        public Entity()
        {
            qItems = new HashSet<EntityItem>();
            readonlyItems = null;
        }

        public virtual Guid Id { get; set; }

        public virtual string Name { get; set; }

        //public virtual IReadOnlyCollection<EntityItem> Items
        //{
        //    get
        //    {
        //        if (readonlyItems == null || readonlyItems.Count != InternalItems.Count)
        //        {
        //            readonlyItems = new ReadOnlyCollection<EntityItem>(InternalItems.ToList());
        //        }
        //        return readonlyItems;
        //    }

        //}

        public virtual bool AddItem(EntityItem item)
        {
            item.Parent = this;
            return qItems.Add(item);
        }

        public virtual bool RemoveItem(EntityItem item)
        {
            item.Parent = null;
            return qItems.Remove(item);
        }

        ISet<EntityItem> qItems;
        ISet<EntityItem> IQueryableItems.InternalItems { get { return qItems; } set { qItems = value; } }

    }

    public class EntityItem : IEquatable<EntityItem>
    {
        public virtual Guid Id { get; set; }

        public virtual string Description { get; set; }

        public virtual Entity Parent { get; set; }

        public override bool Equals(System.Object obj)
        {
            // If parameter is null return false.
            if (obj == null)
            {
                return false;
            }

            // If parameter cannot be cast to Point return false.
            EntityItem p = obj as EntityItem;
            if ((System.Object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (Id == p.Id);
        }

        public virtual bool Equals(EntityItem p)
        {
            // If parameter is null return false:
            if ((object)p == null)
            {
                return false;
            }

            // Return true if the fields match:
            return (Id == p.Id);
        }

        public override int GetHashCode()
        {
            return 23 ^ Id.GetHashCode();
        }
    }
}

{'fraction_non_alphanumeric': 0.08438978240302744, 'fraction_numerical': 0.0007568590350047304, 'mean_word_length': 1.318421052631579, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6858683', 'n_tokens_mistral': 1354, 'n_tokens_neox': 1273, 'n_words': 365}