littleguru wrote:
SecretSoftware wrote:
Thanks for your reply LittleGuru. I read the bug report you filed, and I am upset by this change
I had to change my ORM to work with dynamic types... Usually i create an instance of an object (you can even specify a factory for it) and set the property values afterwards. For anonymous types I had to change that to call the constructor with the values...
Btw. does somebody know how to detect if a type is an anonymous type? I have seen that there is the CompilerGeneratedAttribute set on them and that they have a weird name, but is there any other thing I could do... There's no property on the type that returns true for an anonymous type? - I haven't found one so far
But the whole point of anonymous types is that they are anonymous, where their type is not important to know, and you just want a class that holds data groups together.
However, You can make a property when you construct it. And modify to work with your specific logic? There might be a way using reflection, but I am not sure about this though.
var cust1 = new { Name = "LittleGuru", Address = "Planet Earth" ,
IsAnonymousType = true};
Edit: You could do this?
var cust1 = new { Name = "LittleGuru", Address = "Planet Earth" };
if (cust1.GetType().ToString().Contains("AnonymousType"))
Console.WriteLine("Yes!!");
else
Console.WriteLine("NO!!");
Console.ReadLine();