문제

In the webMatrix examples, which I have working, it's very easy to access a database. Only three lines are necessary to get up and going:

@{
    var db = Database.Open("LOS"); 
    var selectQueryString = "SELECT * FROM wknTest";
}

and a little later,

 @foreach(var row in db.Query(selectQueryString)){ 

There's no using's, no connection strings, all that happens behind the scenes. But now I have enough complicated c# code that I want to separate it into a separate C# file. How would I do the above, but in a C# file residing in the app_code folder in a webMatrix project?

도움이 되었습니까?

해결책

From scrounging around, I found I was missing the reference to one of these. I'm not sure if one or both are needed, so I'll not mark the question answered and hopefully someone more knowledgeable than my scrounging will know.

using WebMatrix.WebData;
using WebMatrix.Data;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top