Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Building a common library for .Net Applications

Posted on 2014-03-17
3
Medium Priority
?
274 Views
Last Modified: 2014-03-24
Hi guys,

I am jumping into the world of OOP. For start can you please advise me in building a library  which contains classes like connection string  and open close, Classes which return update, insert and delete query, classes which return list<t> or data sets. I am looking to build this library generic to use with different applications.

kindest regards,
0
Comment
Question by:shah36
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Expert Comment

by:Lucky Ncube
ID: 39934034
Here is an example of how I do it using Classes.
1. Define class called tblCIty to present my database table called tblCIty. Please note that this is an instantiating class
Public Class tblCity

    Property CityID As Guid
    Property City As String

    Sub New()

    End Sub
    Sub New(ByVal sqlRdr As SqlDataReader)
        _CityID = sqlRdr("CityID")
        _City = sqlRdr("City")
    End Sub
    Public Overrides Function ToString() As String
        Return _City
    End Function

End Class

Open in new window


After I have by class I can use the class to now list the Cities by add them to the List as Shown Below:
Public Shared Function List(ByVal sqlConn As SqlConnection, Optional ByVal sqlTrans As SqlTransaction = Nothing) As List(Of tblCity)
        Dim iList As New List(Of tblCity)
        Using sqlCmd As New SqlCommand("City_List", sqlConn, sqlTrans)
            sqlCmd.CommandType = CommandType.StoredProcedure
            Using sqlRdr As SqlDataReader = sqlCmd.ExecuteReader
                While sqlRdr.Read
                    iList.Add(New tblCity(sqlRdr))
                End While
                sqlRdr.Close()
            End Using
        End Using
        Return iList
    End Function

Open in new window

This  simple object manipulating code.
0
 
LVL 20

Accepted Solution

by:
Daniel Van Der Werken earned 2000 total points
ID: 39934407
This kind of thing has been done a lot. Your question doesn't have any easy or simple one-page answer. First, I would direct you to libraries that already exist that provide for this functionality in the .NET framework. Mainly, the Entity Framework:
http://msdn.microsoft.com/en-us/data/ef.aspx

Otherwise, a simple web search on ".net c# crud framework" will give you a bunch of options to choose from.
0
 

Author Closing Comment

by:shah36
ID: 39950535
Thanks gave me the start
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question