Bonjour, j'ai créé un site Web vide C#. J'ai créé une base de données et je suis en train de lire le contenu d'un .cshtmlVisual Studio 2013 WebSite Project Database.Open
@{
var db = WebMatrix.Data.Database.Open("Test");
var selectQueryString = "SELECT * FROM Product ORDER BY Name";
}
<html>
<body>
<h1>Small Bakery Products</h1>
<table>
<tr>
<th>Id</th>
<th>Product</th>
<th>Description</th>
<th>Price</th>
</tr>
@foreach (var row in db.Query(selectQueryString))
{
<tr>
<td>@row.Id</td>
<td>@row.Name</td>
<td>@row.Description</td>
<td align="right">@row.Price</td>
</tr>
}
</table>
</body>
</html>
au début, je suis une erreur
Erreur 1 Le nom de « base de données » n'existe pas dans le contexte actuel
qui a été fixé après que je l'ai fait https://www.nuget.org/packages/WebMatrix.WebData/
maintenant j'obtiens une erreur de message
erreur 1 La méthode d'initialisation de démarrage préalable à la demande de démarrage du type WebMatrix.WebData.PreApplicationStartCode a généré une exception avec le message d'erreur suivant: Tentative par la méthode de sécurité transparent 'WebMatrix.WebData.PreApplicationStartCode.Start() pour accéder à la sécurité méthode critique 'System.Web.WebPages.Razor.WebPageRazorHost.AddGlobalImport (System.String)' a échoué ..
double possible ([tentative de méthode transparente de sécurité 'WebMatrix.WebData.PreApplicationStartCode.Start()'] http://stackoverflow.com/questions/17926552/attempt-by- sécurité-transparent-méthode-webmatrix-webdata-preapplicationstartcod) – Paddy