views:

130

answers:

1

Hi, I am moving 1 project, just the data tier, the project is using MVC 1.0 and acess mdb :S

Now I am moving to SubSonic + Sql server and all is fine, except when I try to implement to my class IDataErrorInfo for validation messages, I get always 2 times every error message

I have a table class generated by subsonic:MyTable, then I extend it.

public partial class myTable : IDataErrorInfo{
public string this[string columnName]{
    get{
        switch (columnName.ToUpperInvariant()){
            case "MYFIELD":
                if (string.IsNullOrEmpty(myField)){
                    return "Incorrect MyField";
                }
                break;
            case "ANOTHER":
                if (string.IsNullOrEmpty(myField)){
                    return "Incorrect Another";
                }
                break;
        }
        return "";
    }
}

public string Error{
    get{
        return "";
    }
}

}

In My Controller I add to my post action this code:

public class mycontroller...{
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult myAction(int id, MyTable data)
{
    try
    {
        UpdateModel(data, new[] { "MyField","Another" });
        data.Save();
        return RedirectToAction("Admin");
    }
    catch (Exception ex)
    {
        //ViewData["Error"] = ex.Message;
        return View(data);
    }
}

My view have a summary generated as Html.ValidationSummary("Attention:")

When I get invalid data My summary get 2 times the error as it:

Attention:
Incorrect MyField
Incorrect MyField
Incorrect Another
Incorrect Another

I don't want to rewrite the validation form, here is a lot of views (about 130). I think the problem is in some place in subsonic, but I can't get where :S, Please help me :)

Best regards and thanks in advance.

no way to catch this error :(

A: 

Which version of SubSonic are you using? IIRC, Save() in v2.0.3 could call the validation method twice.

kevinw
I download the source from google the latest subsonic 2.2, just 5 days ago, and compiled it. where is calling it 2 times the validation method ? I am going to look it, thanks.
Jorge Mota
OH, I forgot to say, I get it, vía SVN.thanks
Jorge Mota
The "bug" of the double calling was in the previous SubSonic 2.0.32.1 (and 2.2) don't have this. Your problem must be something else.
kevinw
Implementing this interface in latest 3.0 result in a Error in toDictionary method, I am thinking in moving me to EntityFramework.
Jorge Mota
Problem implementing Entity Framework is rewrite all my work done with Subsonic :(
Jorge Mota