1

This question is complicated, but I hope you will understand my problem. I'm using databases for the first time, sql server with dataset and adapters. This is my application in brief:

I have MainManager that calls the method (LoadData) in the MotelManager and that method then calls the method (LoadDataFromDB) in DataAccess that is a DLL project.

My question and need for help and understanding is to begin with, how do I get the values from the columns in each row back to the calling method in MainManager?

One way could perhaps be to create some temporarily object like the code below and pass that object back, but I can't create an instance of it in DataAccess!? I'm always get's in trouble when it's about references and namespace :( Is this the best and simpliest way? Help is preciated! Thanks!

    public class TempObj
{
    public string Id { get; set; }
    public string Name { get; set; }
    public string Age { get; set; }
    public string Gender { get; set; }
    public string Type { get; set; }
    public string Category { get; set; }
    public string Info { get; set; }

    public TempObj()
    {
    }
} 
2
  • R u using a service to call your dll ? Commented Aug 7, 2012 at 6:50
  • Typed DataTables? Hmm, what do you mena? Commented Aug 7, 2012 at 6:56

1 Answer 1

1

You're going to need to "map" data in a class, as you already guessed. But there's no build the whole mapping structure from scratch.

You can use Entity Framework (a.k.a. "EF") which is an infrastructure to automatically generate classes which reflect your database. MSDN, as in most cases, is your best friend here: Getting Started (Entity Framework)

Sign up to request clarification or add additional context in comments.

1 Comment

Not at all, it's the first which came to mind because it's Microsoft's, and in my case is the one I'm the most familiar with. Alternatives are all along the lines of this though, and FYI it looks way harder than it really is to implement. Visual Studio takes care via wizards of almost all the "behind the scenes" work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.