Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8495821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:40:58+00:00 2026-06-10T23:40:58+00:00

public class Question { public int Id { get; set; } public int? Score

  • 0
public class Question
    {
        public int Id { get; set; }
        public int? Score { get; set; }
        public string Title { get; set; }
        public List<string> Tags { get; set; }
        public Owner Owner { get; set; }
        public Uri Link { get; set; }
        public bool IsAnswered { get; set; }
    }

public class Owner
    {
        public int? ID { get; set; }
        public String Name { get; set; }
        public int Reputation { get; set; }
        public Uri Link { get; set; }
    }

public static dynamic CallStackOverFlow()
        {
            var client = new RestClient("https://api.stackexchange.com/2.1");
            var request = new RestRequest("/search/advanced", Method.GET);
            request.RequestFormat = DataFormat.Json;
            request.AddParameter("site", "stackoverflow");
            request.AddParameter("tagged", "C#");
            request.AddParameter("pagesize", "1");
            var response = client.Execute(request);
            var content = response.Content; // raw content as string
            dynamic deserialised = JsonConvert.DeserializeObject(content);
            return deserialised;
        }

//go call stackoverflow
            var d = StackOverflow.CallStackOverFlow();
            var questions = new List<Question>();
            foreach (var q in d.items)
            {
                Console.WriteLine(q);
                var question = new Question
                {
                    Id = q.question_id,
                    IsAnswered = q.is_answered,
                    Link = new Uri(q.link == null ? "" : (string)q.link),
                    Owner = new Owner
                    {
                        ID = q.owner.user_id,
                        Link = new Uri(q.owner.link == null ? "" : (string)q.owner.link),
                        Name = q.owner.display_name,
                        Reputation = q.owner.reputation
                    },
                    Tags = (q.tags as JArray).Values().Select(v => v.ToString()).ToList(),
                    Score = q.score,
                    Title = q.title
                };

                questions.Add(question);
            }
            using (IDocumentStore documentStore = new DocumentStore() { Url = "http://localhost:8080", DefaultDatabase = "StackOverflow" })
            {
                documentStore.Initialize();
                using (IDocumentSession session = documentStore.OpenSession())
                {
                    session.Store(questions);
                    session.SaveChanges();
                }
            } 

I am just starting out with RavenDb so forgive me if this sounds a bit stupid.
I went through the client api…can’t figure out why am I getting the following exception..

Object serialized to Array. RavenJObject instance expected.

I did try to cast a the list to an array …even though it did not feel right.. that failed as well.. Further , Why do I have to dela with RavenJObject and RavenJArray instead of the default that comes with Json.net.. I am guessing there is nifty work going on under the hood..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:40:59+00:00Added an answer on June 10, 2026 at 11:40 pm

    The exception is occurring because you are attempting to store an array of questions when you call: session.Store(questions);

    The api is expecting to receive an entity to persist not an array or collection.

    You may want to make use of batch operations to handle the loading of a bunch of questions: http://ravendb.net/docs/client-api/advanced/databasecommands/batch

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Question class: class Question { public int QuestionNumber { get; set;
I have simple type Question : public class Question { public string[] Tags {
I have the following entity public class Employee { public virtual int Id {get;set;}
Let's have a model public class Model { public int Number { get; set;
Given the following object, public class Question { [Required] public string QuestionText { get;
Lets assume: List<element> which element is: public class Element { int Weight { get;
public class Filter { public int A { get; set; } public int B
Simple question on best practice. Say I have: public class Product { public string
I got a controller action like public class Question { public int Id {
This demo class to explain the question public class SomeClass { public string Name

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.