How can I do this?
Doing it this way could save a lot of code (instead of implementing an interface in each class)
Is this possible?, is there any other way to make this?
public SqlDataLayer : DataLayer
{
}
public OleDbDataLayer : DataLayer
{
}
abstract class Base { public void TellMyName() { Console.WriteLine(String.Format("My name is {0}", this.GetType().Name)); } } class Class1 : Base { private string customThing; } class Class2 : Base { public long whatever; } class Program { static void Main(string[] args) { Class1 prod1 = new Class1(); prod1.TellMyName(); Class2 prod2 = new Class2(); prod2.TellMyName(); Console.ReadLine(); } } |
What about something like this:
abstract class Base { protected virtual int Identifier { get; } } class Class1 : Base class Class2 : Base |
I believe that any DataLayer must be a simple code block, that they allow operations against DB.
That code block would not have to know on the Business Entities. Single to specialize it is to execute the operations (Store Procedures and SQL Sentences) against the engine DB (SQL, Oracle, DB2, etc.), with which this setting.
Finally, I invite to you to download the DataLayer.Primitives Public Version.
This is very cool Data Layer :)
DataLayer.Primitives - Readme!
http://forums.microsoft.com/msdn/ShowPost.aspx?PostID=1389
Cheers,
Javier Luna
http://guydotnetxmlwebservices.blogspot.com/