Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. Generic Data Access Object

Generic Data Access Object

Scheduled Pinned Locked Moved .NET (Core and Framework)
cssasp-netdatabasebusinesssales
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    snouto
    wrote on last edited by
    #1

    In MVC , we create a business object that represents a table fields may be with the same column names or with other names then create public properties to get and set those values . that is totally fine until now . then i want to display that Object in a grid , i will assign the datasource property to a ILIST,Ienumerable,IDataSource object like for example List< of One business objects > then the grid will iterate through the collection of objects getting every object and accessing the properties names that will reflect the column names in the grid , and the values of those properties will be assigned to the column values in the grid like for example // we have this business object public class Customer { string FName; string LName; public string FirstName { get { return this.FName;} set { this.FName = value;} } public string LastName { get { return this.LName;} set { this.LName = value;} } } now to display that class to the grid i will put it into a list for example then the grid will iterate through the list , reading each object public properties to draw the column names the grid will have the same column names like the public properties then accessing these properties values to display it to the grid . i need to make a business object to be displayed in the grid but the problem is that the business object in my task doesn't have public properties , the public properties are replaced with a data structure that reads the table schema , "Generic Business Object" that is modifiable according to the table schema inside the data base but finally i need to display each Generic Object to the data source controls like grid

    Human knowledge belongs to the world.

    J 1 Reply Last reply
    0
    • S snouto

      In MVC , we create a business object that represents a table fields may be with the same column names or with other names then create public properties to get and set those values . that is totally fine until now . then i want to display that Object in a grid , i will assign the datasource property to a ILIST,Ienumerable,IDataSource object like for example List< of One business objects > then the grid will iterate through the collection of objects getting every object and accessing the properties names that will reflect the column names in the grid , and the values of those properties will be assigned to the column values in the grid like for example // we have this business object public class Customer { string FName; string LName; public string FirstName { get { return this.FName;} set { this.FName = value;} } public string LastName { get { return this.LName;} set { this.LName = value;} } } now to display that class to the grid i will put it into a list for example then the grid will iterate through the list , reading each object public properties to draw the column names the grid will have the same column names like the public properties then accessing these properties values to display it to the grid . i need to make a business object to be displayed in the grid but the problem is that the business object in my task doesn't have public properties , the public properties are replaced with a data structure that reads the table schema , "Generic Business Object" that is modifiable according to the table schema inside the data base but finally i need to display each Generic Object to the data source controls like grid

      Human knowledge belongs to the world.

      J Offline
      J Offline
      Jon Rista
      wrote on last edited by
      #2

      I am not sure what value a business object without properties poses. If you need some kind of generic data storage and transfer facility, I highly recommend that you use DataSet/DataTable/DataView. These are, for all intents and purposes, generic "business objects" that can take on the traits of a table, such as the same columns filled with rows of data from that table. You can then bind the DataTable, or if you need sorting and filtering, a DataView wrapped around that DataTable, to the GridView. Once you have that, there are more than enough resources on the internet that explain how to bind a DataTable/DataView to a grid.

      S 1 Reply Last reply
      0
      • J Jon Rista

        I am not sure what value a business object without properties poses. If you need some kind of generic data storage and transfer facility, I highly recommend that you use DataSet/DataTable/DataView. These are, for all intents and purposes, generic "business objects" that can take on the traits of a table, such as the same columns filled with rows of data from that table. You can then bind the DataTable, or if you need sorting and filtering, a DataView wrapped around that DataTable, to the GridView. Once you have that, there are more than enough resources on the internet that explain how to bind a DataTable/DataView to a grid.

        S Offline
        S Offline
        snouto
        wrote on last edited by
        #3

        Thank you jon rista , but my Manager doesn't recommend for me a datatable or dataview , i don't know why . i tried to convince him to use these tools but he refused , he tries to confuse me a little . Anyway , i thank you very much for your response and consideration

        Human knowledge belongs to the world.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups