Pregunta

I'm trying to pass a anonymous type to a function in VB.NET but I only know how to do it in C#. Is there a way to do this in VB.NET using VS2012.

This example was taken from the PetaPoco reference.

 sql.Append("AND date_created>=@start AND date_created<=@end", 
            new 
            { 
                start=DateTime.UtcNow.AddDays(-2), 
                end=DateTime.UtcNow 
            }
        );

EDIT I had used the wrong terminology, the documentation for petapoco used named parameter when it's actually an anonymous type. I should have seen that. I would've figured that out in that case. I changed the question to reflect this.

¿Fue útil?

Solución

Those aren’t named parameters; that’s one anonymous type. Exactly the same thing looks like this in VB.NET:

sql.Append("AND date_created>=@start AND date_created<=@end", New With {
    Key .start = DateTime.UtcNow.AddDays(-2),
    Key .end = DateTime.UtcNow
})
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top