CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Threaded View

  1. #1
    Join Date
    Feb 2001
    Posts
    2,455

    Data Table to Business Object Mapping.

    In the past while I have looked into several techniques adopted for mapping relational data to business object. In O/R mappers, there seems to be two main methods, using XML files or Attributes.

    I am just curious, why not just use static methods?

    Code:
    public interface IBaseBusinessObject
    {
          string GetTable();
          Dictionary<string,string> GetMapping();
    }
    
    public class MyBusinessObject : IBaseBusinessObject
    {
          static string tableName = "MyTableName";
          static Dictionary<string, string> mapping = new Dictionary<string,string>
          {
               {"PropertyA", "ColumnA"},
               {"PropertyB", "ColumnB"},
               {"PropertyC", "ColumnC"}
          }
    
          public static string GetTable()
         { 
               return tableName;
         }
    
         public static Dictionary<string,string> GetMapping()
         {
              return mapping;
         }
    }
    To me it seems to make more sence mapping using this method then having to deal with reading attributes. But, I have yet to see an O/R Mapper implemented in this way and I am wondering why not?

    Any thoughts?

    Mike B
    Last edited by MikeB; April 15th, 2009 at 08:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured