public ContentInfo GetInfo <T>()
     where T : IQPArticle
 {
     return(MappingResolver.GetContent(typeof(T).Name));
 }
        private void UpdateObjectStateEntries(IEnumerable <EntityEntry> entries, Func <ContentInfo, EntityEntry, string[]> getProperties, bool passNullValues)
        {
            var links = entries.Where(x => typeof(IQPLink).IsAssignableFrom(x.Entity.GetType())).ToList();

            foreach (var group in entries.Where(e => !typeof(IQPLink).IsAssignableFrom(e.Entity.GetType())).GroupBy(m => m.Entity.GetType().Name))
            {
                var contentName = group.Key;
                var content     = MappingResolver.GetContent(contentName);
                if (!content.IsVirtual)
                {
                    var items = group
                                .Where(item => item.Entity is IQPArticle)
                                .Select(item => {
                        var article     = (IQPArticle)item.Entity;
                        var properties  = getProperties(content, item);
                        var fieldValues = GetFieldValues(contentName, article, properties, passNullValues);
                        if (fieldValues.ContainsKey("CONTENT_ITEM_ID") && Int32.Parse(fieldValues["CONTENT_ITEM_ID"]) < 0)
                        {
                            fieldValues["CONTENT_ITEM_ID"]  = "0";
                            item.Property("Id").IsTemporary = false;
                        }
                        AddLinksToUpdate(article, fieldValues, links);
                        return(new
                        {
                            article,
                            fieldValues
                        });
                    })
                                .ToArray();

                    Cnn.MassUpdate(content.Id, items.Select(item => item.fieldValues), 1);

                    foreach (var item in items)
                    {
                        SyncArticle(item.article, item.fieldValues);
                    }
                }
            }

            foreach (var e in entries.Where(x => typeof(IQPLink).IsAssignableFrom(x.Entity.GetType())))
            {
                if (((IQPLink)e.Entity).Id <= 0)
                {
                    ((IQPLink)e.Entity).Id = ((IQPLink)e.Entity).Item.Id;
                    var p = e.Properties.Where(n => n.Metadata.Name != "ItemId" && !n.Metadata.Name.EndsWith("LinkedItemId") &&
                                               n.Metadata.Name.EndsWith("ItemId")).FirstOrDefault();
                    e.Property(p.Metadata.Name).IsTemporary = false;
                }
                if (((IQPLink)e.Entity).LinkedItemId <= 0)
                {
                    ((IQPLink)e.Entity).LinkedItemId = ((IQPLink)e.Entity).LinkedItem.Id;
                    var p = e.Properties.Where(n => n.Metadata.Name != "LinkedItemId" && n.Metadata.Name.EndsWith("LinkedItemId")).FirstOrDefault();
                    e.Property(p.Metadata.Name).IsTemporary = false;
                }
            }

            var relations = (from e in links
                             where typeof(IQPLink).IsAssignableFrom(e.Entity.GetType())
                             let Id = ((IQPLink)e.Entity).Id
                                      let relatedId = ((IQPLink)e.Entity).LinkedItemId
                                                      let attribute = MappingResolver.GetAttribute(e.Metadata.Name.Substring(e.Metadata.Name.LastIndexOf(".") + 1))
                                                                      let item = new
            {
                Id = Id,
                RelatedId = relatedId,
                ContentId = attribute.ContentId,
                Field = attribute.MappedName
            }
                             group item by item.ContentId into g
                             select new { ContentId = g.Key, Items = g.ToArray() }
                             )
                            .ToArray();

            foreach (var relation in relations)
            {
                var values = relation.Items
                             .GroupBy(r => r.Id)
                             .Select(g =>
                {
                    var d = g.GroupBy(x => x.Field).ToDictionary(x => x.Key, x => string.Join(",", x.Select(y => y.RelatedId)));
                    d[SystemColumnNames.Id] = g.Key.ToString();
                    return(d);
                })
                             .ToArray();

                Cnn.MassUpdate(relation.ContentId, values, 1);
            }
        }