Click here to Skip to main content
15,905,782 members
Home / Discussions / C#
   

C#

 
Questionbackup and restore [modified] Pin
sos_amin15-Sep-09 23:25
sos_amin15-Sep-09 23:25 
AnswerRe: backup and restore Pin
Harvey Saayman15-Sep-09 23:30
Harvey Saayman15-Sep-09 23:30 
AnswerOh Hang on Pin
Keith Barrow15-Sep-09 23:31
professionalKeith Barrow15-Sep-09 23:31 
AnswerRe: backup and restore Pin
rakesh_choudhury15-Sep-09 23:47
rakesh_choudhury15-Sep-09 23:47 
AnswerRe: backup and restore Pin
Harvey Saayman15-Sep-09 23:52
Harvey Saayman15-Sep-09 23:52 
AnswerRe: backup and restore Pin
Christian Graus16-Sep-09 1:30
protectorChristian Graus16-Sep-09 1:30 
QuestionInheritance Problem. Can I do this? Pin
TheFoZ15-Sep-09 23:13
TheFoZ15-Sep-09 23:13 
AnswerRe: Inheritance Problem. Can I do this? Pin
dojohansen15-Sep-09 23:35
dojohansen15-Sep-09 23:35 
The short answer is "yes". Smile | :)

I think it's a slightly odd dependency pattern you're creating - your DALs will depend on the business layer - but it is possible. And you don't need to reference the DAL from the UI - just the business layer.

In your business layer you'll have:

public class StaffMember
{
    virtual public string Name { get; set; }
}


and in the Oracle DAL

public class StaffMemberOracle : StaffMember
{
    [SomeAttribute]
    override public string Name { get; set; }
}


You never actually "convert" between these two types: The derived class IS the base class plus something of it's own.

public StaffMember LoadStaffMember(int id)
{
   // Returns instances of derives classes like StaffMemberOracle.
   // Even though the declared return type is "StaffMember", if you
   // return an instance of StaffMemberOracle, the attribute on the
   // Name property is present.
   switch (DB)
   {
      case "Oracle": return OracleDAL.LoadStaffMember(id);
      case "MSSQL": return MssqlDAL.LoadStaffMember(id);
      ...
   }
}


Not that I'd do that! Rather than have a bunch of switches in every method in the business layer that uses the DAL, create an interface that all DALs implement. Then your code will be something like

public StaffMember LoadStaffMember(int id)
{
   return CreateDAL().LoadStaffMember(id);
}

public Something LoadSomething(int id)
{
   return CreateDAL().LoadSomething(id);
}

IDAL CreateDAL()
{
   get
   {
     switch (DB)
     {
        case "O": return new OracleDAL();
        case "MS": return new MsSqlDAL();
        ...
     }
   }
}


HTH
GeneralRe: Inheritance Problem. Can I do this? Pin
TheFoZ16-Sep-09 1:49
TheFoZ16-Sep-09 1:49 
GeneralRe: Inheritance Problem. Can I do this? Pin
dojohansen16-Sep-09 2:06
dojohansen16-Sep-09 2:06 
AnswerRe: Inheritance Problem. Can I do this? Pin
TheFoZ16-Sep-09 2:08
TheFoZ16-Sep-09 2:08 
GeneralRe: Inheritance Problem. Can I do this? Pin
dojohansen16-Sep-09 3:33
dojohansen16-Sep-09 3:33 
GeneralRe: Inheritance Problem. Can I do this? Pin
TheFoZ16-Sep-09 3:50
TheFoZ16-Sep-09 3:50 
QuestionC# program deployment issue Pin
spankyleo12315-Sep-09 23:08
spankyleo12315-Sep-09 23:08 
AnswerRe: C# program deployment issue Pin
Christian Graus15-Sep-09 23:12
protectorChristian Graus15-Sep-09 23:12 
AnswerRe: C# program deployment issue Pin
musefan15-Sep-09 23:16
musefan15-Sep-09 23:16 
GeneralRe: C# program deployment issue Pin
spankyleo12315-Sep-09 23:28
spankyleo12315-Sep-09 23:28 
GeneralRe: C# program deployment issue Pin
musefan15-Sep-09 23:40
musefan15-Sep-09 23:40 
Questionhow to take the text of an item in a checkedlistbox Pin
billy dev15-Sep-09 22:00
billy dev15-Sep-09 22:00 
AnswerRe: how to take the text of an item in a checkedlistbox Pin
Christian Graus15-Sep-09 22:03
protectorChristian Graus15-Sep-09 22:03 
AnswerRe: how to take the text of an item in a checkedlistbox Pin
Abhishek Sur15-Sep-09 22:21
professionalAbhishek Sur15-Sep-09 22:21 
QuestionHow to log-on a windows xp user Pin
SummerBulb15-Sep-09 21:56
SummerBulb15-Sep-09 21:56 
AnswerRe: How to log-on a windows xp user Pin
Christian Graus15-Sep-09 22:00
protectorChristian Graus15-Sep-09 22:00 
AnswerRe: How to log-on a windows xp user Pin
musefan15-Sep-09 22:00
musefan15-Sep-09 22:00 
GeneralRe: How to log-on a windows xp user Pin
SummerBulb15-Sep-09 22:06
SummerBulb15-Sep-09 22:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.