문제

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.

도움이 되었습니까?

해결책

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
})
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top