The EntitySpaces Community

Share and learn about the EntitySpaces Architecture.
Welcome to The EntitySpaces Community Sign in | Join | Help
in
Home Forums Photos

DataSet Fill / Class Files

Last post 08-27-2008, 6:02 PM by David.Parsons. 2 replies.
Sort Posts: Previous Next
  •  08-27-2008, 9:58 AM 10969

    DataSet Fill / Class Files

    Hello, I am still getting familiar with EntitySpaces.  Theses are a couple of questions I have.

     1.) When using asp.net I usually write class files.  For example, I might create one called "Agency" and within the class I have various functions, Insert, update, delete, getcustomerlisting and so forth.  Can this same type of model be followed utilizing EntitySpaces?  Do I do this in the "Custom" folder or should I create my own.  I just don't want to accidently delete my code if I do another generate.

    2.) As mentioned above I usualy write class files for my asp.net web projects.  One function I use is getting a listing records by filling a dataset.  For instance, GetAgencyListing as the code shows below.  How would I utilize Entity Spaces and fill a dataset similiar to what I am doing below.

     

    Code:
    public static DataSet GetAgencyListing(bool l_Inactive, bool l_All) 
        { 
            DataSet objDataSet; 
            //-- Create Instance of Connection and Command Object 
            SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings("MY_connectionstring").ToString); 
            SqlCommand myCommand = new SqlCommand("SP_AgencyGetListing", myConnection); 
            
            //-- Mark the Command as a SPROC 
            myCommand.CommandType = Data.CommandType.StoredProcedure; 
            
            
            myCommand.Parameters.AddWithValue("@_AGEN_Inactive", l_Inactive); 
            myCommand.Parameters.AddWithValue("@_AGEN_ALL", l_All); 
            
            SqlDataAdapter result = new SqlDataAdapter(myCommand); 
            objDataSet = new DataSet(); 
            result.Fill(objDataSet); 
            
            myConnection.Close(); 
            myConnection.Dispose(); 
            myCommand.Dispose(); 
            return objDataSet; 
            
        } 
    
  •  08-27-2008, 10:46 AM 10974 in reply to 10969

    Re: DataSet Fill / Class Files

    Why do you need the dataset? With EntitySpaces you can assign the collections to the data source properties.

    There is also (I think) a protected method you can put in your Custom classes, called FillDataTable.


    Current Projects:
    iVirtualDocket | iWontRemember
  •  08-27-2008, 6:02 PM 10986 in reply to 10969

    Re: DataSet Fill / Class Files

    iVirtualDocket makes a good point. You may not have to use a DataSet.

    Take a look at the example here in the EntitySpaces API chm file installed to your start menu.

    EntitySpaces.Core->esEntityCollection->Load(esQueryType, String, esParameters)

    If you put the method in your AgencyCollection Custom class, it will populate it rather than a DataSet. The QueryType can be StoredProcedure, and instead of raw text, just pass in the name of your SP. The bool returned will be true if at least one record was returned.

    If you need a DataSet rather than populating your collection there are a number of overloads for that as well.

    EntitySpaces.Core->esEntityCollection->FillDataSet()
     
    It, too, is a protected method that you can use in your Custom class. In either case, you pass in esParameters, and EntitySpaces will handle opening and closing the connection for you.

    The Custom Master is set to not over-write files with the same name. But, for regeneration you would only run the Generated Master, unless new tables were added.


    David Neal Parsons
    www.entityspaces.net
View as RSS news feed in XML