Created
November 14, 2013 07:32
-
-
Save tenfortyeight/7462857 to your computer and use it in GitHub Desktop.
How come that the first version doesn't work, but the other do? I am missing something in all the dynamics...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Version 1 - Don't work | |
public IEnumerable<string> GetAll() | |
{ | |
var dataHistory = tbl.All(); //Massive, returns a dynamic object | |
var history = Deserialize(dataHistory); | |
return history; | |
} | |
private IEnumerable<string> Deserialize(dynamic dataHistory) | |
{ | |
foreach (dynamic dataMessage in dataHistory) //This will blow up: Massive.DynamicModel.Query(string, params object[])' is a 'method' but is used like a 'type' | |
{ | |
using (var stream = new MemoryStream(dataMessage.Payload)) | |
{ | |
//do stuff | |
yield return; | |
} | |
} | |
} | |
//Version 2: this works just fine. Same thing but not passing in the dynamic object as a parameter | |
public IEnumerable<string> GetAll() | |
{ | |
dynamic tbl = new MessageHistory(); | |
var dataHistory = tbl.All(); | |
var history = new List<string>(); | |
foreach (dynamic dataMessage in dataHistory) | |
{ | |
using (var stream = new MemoryStream(dataMessage.Payload)) | |
{ | |
//do stuff | |
history.Add(message); | |
} | |
} | |
return history; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ops, I mean accepting a IEnumerable< dynamic > in the Deserialize method, not just IEnumerable :)