C#.NET 2.0 class example for data acess layer using microsoft enterpise library

  • Home
  • Blog
  • C#.NET 2.0 class example for data acess layer using microsoft enterpise library

here is the data layer class example…..

///here is the enum

public enum OprationType{Add = 1,Update = 2,Delete = 3

}

//here is the Interfae public interface IDataStatndard{void Operation(OperationType enumOperationType);

}

//here is the user data class

public class UserData : IDataStatndard{#region PrivateMemeberprivate DashBoardCollection.UserCollection _objUserCol;private Database _db;private string _commandName;private DbCommand _dbCommand;#endregion#region Constructorspublic UserData(){}public UserData(DashBoardCollection.UserCollection obj){_objUserCol = obj;}#endregion#region Methodspublic void Operation(OpertaionType enumOperationType){switch (enumOperationType){case OperationType.Add:this.Add();break;case OperationType.Update:this.Update();break;case OperationType.Delete:this.Delete();break;}}private void Add(){}private void Update(){}private void Delete(){}public bool CheckUserLogin(){_db = DatabaseFactory.CreateDatabase(“SopraConnect”);_commandName = “usp_CheckUserLogin”;_dbCommand = _db.GetStoredProcCommand(_commandName);_db.AddInParameter(_dbCommand, “username”, DbType.String, this._objUserCol.UserName);_db.AddInParameter(_dbCommand, “password”, DbType.String, this._objUserCol.Password);_db.AddOutParameter(_dbCommand, “isvalid”, DbType.Byte, 1);_db.ExecuteNonQuery(_dbCommand);Byte isValid = Convert.ToByte( _db.GetParameterValue(_dbCommand, “isvalid”));if (isValid == 1)return true;elsereturn false;}#endregion

}