Example #1
0
        public static IEnumerable <EntityWithKey> GetEntities(this RelatedEntities relatedEntities, string collection)
        {
            var list = relatedEntities.GetList(collection);

            if (list != null)
            {
                foreach (var item in list)
                {
                    yield return(item as EntityWithKey);
                }
            }
        }
Example #2
0
        public static void AddEntity(this RelatedEntities relatedEntities, EntityWithKey entity)
        {
            if (entity == null)
            {
                return;
            }

            var type       = entity.GetType();
            var desc       = TypeDescriptor.Get(type);
            var collection = type.Name;

            var list = relatedEntities.GetList(collection);

            if (list == null)
            {
                list = desc.CreateList();
                relatedEntities.SetList(collection, list);
            }

            list.Add(entity);
        }