Solved

adding generated code from a dataset to a class library

Posted on 2007-11-15
9
182 Views
Last Modified: 2013-11-26
I'm new to working with class libraries.  I know that a class library compiles into an assembly that you can use in your applications.

Here is my question.  I am managing an application that has a class library.   I need to add some new code to the class library and generated an updated assembly.

Outside of the class library project, I have another web application project and I added a new dataset that has two datas tables and two table adapters.  I have a page that uses these table adapters to bind to a couple of repeaters that dispaly the information from the data tables.  All that works fine.

Now, what I want to do, is move the code into the class library and re-compile, so the code from the dataset can be rolled up into the assembly.

I have no idea how to do this?

Can anyone help?  I would greatly appreciate any guidance on how to accomplish this.

Thank you.
0
Comment
Question by:-Dman100-
  • 5
  • 4
9 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20298135
If you are looking to generate dynamic code, then look into CodeDom.  I don't think that you will not be able to modify an existing class library.  You can, however, compile the code in to a separate AppDomain, so that you can load/unload the DLL.

CodeDom Example:

How Do I...Use the CodeDOM to emit source code?
http://quickstart.developerfusion.co.uk/QuickStart/howto/doc/listbuilder.aspx

Bob
0
 

Author Comment

by:-Dman100-
ID: 20298402
Hi Bob,

Thanks for replying to my post.  So, I cannot add the classes created by the Dataset into the existing class library.  Since I have the class library, I can add new classes and re-compile, which is why I thought I could add the classes generated by the dataset into this class library, but there is no way to accomplish that?

Is you suggested, how can I compile the code created by the Dataset as another class library?  Sorry, for the novice questions, I've just never done this before,.

Thanks for your help.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20299037
I think that I misunderstood your question.  I doesn't sound like you aren't talking about generating dynamic code, but more about moving a typed DataSet into a class library.  Is this right?

Bob
0
 

Author Comment

by:-Dman100-
ID: 20299153
Hi Bob,

Yes, that is correct.  I just want to move the typed Dataset code into the class library and re-compile the assembly so the typed dataset will be included in the assembly.  Am I articulating what I want to accomplish correctly?

Thanks for your help.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 96

Expert Comment

by:Bob Learned
ID: 20299387
It sounds like you want to put all of your data access stuff into a single DLL.  You should be able to move all the related files for the DataSet into another assembly (if I understand what you're asking), and then add a data access layer class that will be able to work with the DataSet.

Bob
0
 

Author Comment

by:-Dman100-
ID: 20299558
Bob,

Yes, I want to use a single DLL.

How do I move the related files for the Dataset into the class library.  There is already a data access layer in the class library.  I guess I need ot create the new class to work with the DataSet.

Is there an article that describes how to do this?

I'm still relatively new to .NET and know how to create the dataset and bind controls using the TableAdapters created in the dataset, but just not how to move those into a class library.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 20300206
1) There are 4 files associated with a typed DataSet:

DataSet1.xsd
DataSet1.Designer.cs
DataSet1.xsc
DataSet1.xss

2) Open Windows Explorer, and move the files from the current folder to the class library folder.  

3) Modify the .csproj to remove the files from the main project, and include them in the class library project.

4) In the data access layer class, create an instance of a typed DataSet, and provide methods to get access to the dataset.

Bob
0
 

Author Comment

by:-Dman100-
ID: 20300375
Sorry to be such a pain, but I had a few questions to the steps you listed.

1)  I see the CustomerService.xsd and CustomerService.xss files, but I don't see the CustomerService.Designer.cs file or the CustomerService.xsc files?  Not sure why?  I don't see them in the AppCode folder?

2) Okay, no problem with this one

3)  Not sure how to modify the .csproj file to accomplish this?

4) I might be asking a completely stupid question here, but when the typed dataset was created, didn't it create the methods that access the data that is populated from the database?

I hope my questions make sense and I'm not completely lost?
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 20329700
That description for the files was based on a WinForms application.  For an ASP.NET web site, there would only be the .xsd and the .xss file.

You should be able to use the typed DataSet directly, without any other class required.

Bob
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Normally the drop down box control found in the .Net framework tools is able to select just one data and value at a time, which is displayed on the text area.   But what if you want to have multiple values to be selected in the drop down box? As …
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now