Ich habe 2 Projekte. Ein Datenprojekt, das meine Datenbank und mein Entity Framework-Modell enthält. Ich habe eine Tabelle mit dem Namen "Benutzer" und dann eine generierte EF-Klasse für den Benutzer.ASP.Net (3.5) MVC teilweise Klasse für die Überprüfung der Regel
Ich versuche, eine Teil-Klasse hinzuzufügen:
using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Text;
namespace Data
{
public partial class user
{
public bool isValid
{
get {
return (GetRuleViolations().Count()==0);
}
}
public IEnumerable<RuleViolation> GetRuleViolations()
{
yield break;
}
partialvoid OnValidate(ChangeAction action)
{
if (isValid)
throw new ApplicationException("Rule violation prevents saving");
}
}
public class RuleViolation
{
public string ErrorMessage { get; private set; }
public string PropertyName { get; private set; }
public RuleViolation (string errorMessage)
{
ErrorMessage = errorMessage;
}
public RuleViolation(string errorMessage, string propertyName)
{
ErrorMessage = errorMessage;
PropertyName = propertyName;
}
}
}
Dies wird nach dem NerdDinner Beispiel 1.0 MVC. Allerdings bin ich ein Design-Zeitfehler auf dem OnValidate Methode bekommen:
partial void OnValidate(ChangeAction action)
{
if (isValid)
throw new ApplicationException("Rule violation prevents saving");
}
Keine definining Erklärung für implimenting Erklärung Teil Methode ‚Leere OnValidate (Change action)‘
gefunden Was mache ich falsch?
Ich bin mir immer noch nicht sicher, was ich hier falsch mache. – Craig