PDA

View Full Version : ASP.NET MVC and Linq Issues


Unknown
08-17-2009, 06:10 AM
I have an MVC website that consists of two projects, the WebUI and DatabaseModel.

In my DatabaseModel, I have a few static classes that interact with the database. I define these classes as such:


public static class UserCommands
{
private static mycataContext db;

static UserLogic()
{
db = new mycataContext();
}

public static User GetUser(string UserName)
{
return db.Users.First(x=>x.UserName== UserName);
}

public static bool ValidateUser(string UserName, string Password)
{
User TheUser = GetUser(UserName);
return TheUser.Password == Password;
}

}


I put a reference of DatabaseModel project in WebUI project so that when I need to access functions I refernece the function as such: UserCommands.GetUser("name") or UserCommands.ValidateUser("name", "password")

What the problem is that some functions that update a row in the database don't appear when they're updated. Only once I rebuild the solution do the updates go through. Also, when I updated the database manually via MSSQL Server Management Studio, the updates don't go through unless the solution is rebuilt.

Any help in pointing me in the right direction would be appreciated.