views:

247

answers:

2

Hello:

I use System.Data.SQLite and C# for accesing SQLite databases/tables. For lazy and fast development reasons, I created my own library of classes to encapsulate some of System.Data.SQLite methods in one method, and to create many common database routines (methods) that let me reduce my work when accessing to data.

If I would inherit System.Data.SQLite library instead of referencing it would help me to optimize my work, ¿is this possible? ¿may you give an example, please?

+1  A: 

Inheriting won't be a good idea if you want control over the interface you provide to the users of your class.

If all you are going to do is have a few methods, it would be better to use SQLLite as a data member, rather than inherit from it.

Moron
Moron, let me understand your answer, please. I created methods for reading a flat file with separators and insert into a SQLite table, retrieve all columns from a table into a dictionary, create and populate tables with Active Directory data, insert data from a dictionary<>, etc. May you give an example about using Sqlite library as a data member?
Eduardo
You want to inherit a library? Never heard of such a thing! Perhaps some C# gurus can help you with that.
Moron
A: 

It's possible to inherit from SQLite and make additions to some of the classes, particularly SQLiteConnection. However, you won't be able to use your own classes everywhere as SQLite will internally create a lot of classes like SQLiteCommand and SQLiteParameter and you don't have an option to tell SQLite to use your custom versions. There is a SQLiteFactory, but this is used for ADO.NET data provider integration and is not used internally by SQLite.

You're much better off keeping your methods separate. If you want them to feel like they're part of the library you can use Extension Methods

Sam