Reputation: 9297
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()
{
}
}
Upvotes: 1
Views: 323
Reputation: 23300
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)
Upvotes: 1