示例#1
0
        public UpdateRequest AddObject <T>(IList <T> objs, IDataMappingHandler mappingHandler) where T : class, new()
        {
            if (objs == null)
            {
                throw new ArgumentNullException("objs");
            }
            if (mappingHandler == null)
            {
                throw new ArgumentNullException("mappingHandler");
            }
            var handler = mappingHandler.GetMappingHandler <T>();

            if (handler == null)
            {
                throw new MizoreMappingException(mappingHandler, "Can't map the type " + typeof(T).Name);
            }

            if (_documents == null)
            {
                _documents = new List <SolrInputDocument>();
            }

            foreach (var obj in objs)
            {
                if (obj == null)
                {
                    continue;
                }
                _documents.Add(handler.GetDocument(obj));
            }
            _changed = true;
            return(this);
        }
示例#2
0
        public T GetObject <T>(IDataMappingHandler mapping) where T : class, new()
        {
            if (mapping == null)
            {
                return(null);
            }
            var handler = mapping.GetMappingHandler <T>();

            if (handler == null)
            {
                return(null);
            }
            return(handler.GetObject(Document));
        }
示例#3
0
        public IList <T> GetObjects <T>(IDataMappingHandler mapping) where T : class, new()
        {
            if (mapping == null)
            {
                return(null);
            }
            var handler = mapping.GetMappingHandler <T>();

            if (handler == null)
            {
                return(null);
            }
            var list = new List <T>(Documents.Count);

            foreach (var doc in Documents)
            {
                list.Add(handler.GetObject(doc));
            }
            return(list);
        }