I’m building a webapi and I have strange problem.
When I do something like this
List<Content> items = new List<Content>();
And than i add items to it
items.Add(new Content());
And than I invoke url localhost/api/Content/Get I’ll get a nice xml with my items
But when I do something like this
public IEnumerable<Content> Get()
{
List<Content> population = new List<Content>();
Content[] test = new Content[5];
var tmp = from c in db.Content select c;
using (IEnumerator<Content> enumerator = tmp.GetEnumerator())
{
while (enumerator.MoveNext())
{
Content ctmp = (Content)enumerator.Current;
population.Add(ctmp);
}
}
return population;
}
And I invoke same url I get blank (white) page. Same think when I’ll return the tmp variable.
Update:
thanks for help. Main question is still standing. Why normal List is returned correctly and List created from db isn`t. Making a copy from DataProxies.Content to COntent isn’t the solution that I’ve dreamed off and as Jon noticed it’s a bit odd.
None of samples with db.Content.ToList() helped :/ I’m confuesed
I found the solution. At least I think I did
I use
Than I get normal objects not proxy dynamic entities
About your question Jon. How am I exposing that method ? There is not much to tell. I`ve created ApiController from template and just edited the method
This is whole class. Not much as you can see 🙂