public void ListOnDynamicJsonObjectFromJsonWillFailToBeAJsonList()
		{
			var conventions = new DocumentConvention();

			var jObject = RavenJObject.FromObject(page, conventions.CreateSerializer());

			dynamic dynamicObject = new DynamicJsonObject(jObject);
			Assert.NotNull(dynamicObject.CoAuthors as IEnumerable);
			Assert.NotNull(dynamicObject.CoAuthors.Length);
			Assert.Equal(2, dynamicObject.CoAuthors.Length);
		}
Example #2
0
		private IndexingResult ExtractIndexDataFromDocument(AnonymousObjectToLuceneDocumentConverter anonymousObjectToLuceneDocumentConverter, DynamicJsonObject dynamicJsonObject)
		{
			var newDocIdAsObject = dynamicJsonObject.GetRootParentOrSelf().GetDocumentId();
			var newDocId = newDocIdAsObject is DynamicNullObject ? null : (string)newDocIdAsObject;
			List<AbstractField> abstractFields;

			try
			{
				abstractFields = anonymousObjectToLuceneDocumentConverter.Index(((IDynamicJsonObject)dynamicJsonObject).Inner, Field.Store.NO).ToList();
			}
			catch (InvalidShapeException e)
			{
				throw new InvalidSpatialShapeException(e, newDocId);
			}

			return new IndexingResult
			{
				Fields = abstractFields,
				NewDocId = newDocId,
				ShouldSkip = false
			};
		}
Example #3
0
 private IndexingResult ExtractIndexDataFromDocument(AnonymousObjectToLuceneDocumentConverter anonymousObjectToLuceneDocumentConverter, DynamicJsonObject dynamicJsonObject)
 {
     var newDocId = dynamicJsonObject.GetRootParentOrSelf().GetDocumentId();
     return new IndexingResult
     {
         Fields = anonymousObjectToLuceneDocumentConverter.Index(((IDynamicJsonObject)dynamicJsonObject).Inner, Field.Store.NO).ToList(),
         NewDocId = newDocId is DynamicNullObject ? null : (string)newDocId,
         ShouldSkip = false
     };
 }
Example #4
0
 private IEnumerable<AbstractField> ExtractIndexDataFromDocument(DynamicJsonObject dynamicJsonObject, out string newDocId)
 {
     newDocId = dynamicJsonObject.GetDocumentId();
     return AnonymousObjectToLuceneDocumentConverter.Index(dynamicJsonObject.Inner, indexDefinition,
                                                           Field.Store.NO);
 }
		public void LinqQueryWithStaticCallOnEnumerableIsCanBeCompiledAndRun()
		{
			var indexDefinition = new IndexDefinitionBuilder<Page>
			{
				Map = pages => from p in pages
							   from coAuthor in p.CoAuthors.DefaultIfEmpty()
							   select new
							   {
								   p.Id,
								   CoAuthorUserID = coAuthor != null ? coAuthor.UserId : -1
							   }
			}.ToIndexDefinition(new DocumentConvention());

			var mapInstance = new DynamicViewCompiler("testView",
													  indexDefinition, ".").
				GenerateInstance();

			var conventions = new DocumentConvention();
			var o = RavenJObject.FromObject(page,conventions.CreateSerializer());
			o["@metadata"] = new RavenJObject {{"Raven-Entity-Name", "Pages"}};
			dynamic dynamicObject = new DynamicJsonObject(o);

			var result = mapInstance.MapDefinitions[0](new[] { dynamicObject }).ToList<object>();
			Assert.Equal("{ Id = 0, CoAuthorUserID = 1, __document_id =  }", result[0].ToString());
			Assert.Equal("{ Id = 0, CoAuthorUserID = 2, __document_id =  }", result[1].ToString());
		}
Example #6
0
 private IndexingResult ExtractIndexDataFromDocument(DynamicJsonObject dynamicJsonObject)
 {
 	var newDocId = dynamicJsonObject.GetDocumentId();
 	return new IndexingResult
     {
         Fields = AnonymousObjectToLuceneDocumentConverter.Index(dynamicJsonObject.Inner, indexDefinition,
                                                           Field.Store.NO),
         NewDocId = newDocId is DynamicNullObject ? null : (string)newDocId,
         ShouldSkip = false
     };
 }