Hi all,
I'm designing my DAL layer(s) for our suite of applications and I'm
designing myself in circles, it's gotten to the point where each idea just
mixes me up more :)
We have 3 loosely related applications and I would like to use an assembly
for the DAL in each of them. I have thought of using a single assembly for
all of them with several different classes for providers/application
specific code, thought of a separate assembly for each application, etc.
I have several questions that I'm hoping will lead to some clarity if I can
get them answered and hopefully you can help with some of the answers.
1) Is there a way to share .cs files across several projects? I'm used to
this with C++, but in c# it seems that this results in a copy of the files
into each project. Is there a way to reference a file from another project?
or just a file by itself?
2) Typically, do companies use one giant DAL assembly for all applications
needing a DAL?
3) From what I understand of things, if I wanted to have 3 DAL assemblies
all inheriting a common "base DAL" class, I would have a total of 4
assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies
for each application?
4) Check out my little inheritance thing below, question will follow:
class DALBase
abstract class DAL_AppCommon : DALBase
class DAL_AppCommonMy Sql : DAL_AppCommon
class DAL_AppCommonSq lServer : DAL_AppCommon
abstract class DAL_AppInventor y : DALBase, DAL_AppCommon
class DAL_AppInventor yMySql : DAL_AppInventor y
class DAL_AppInventor ySqlServer : DAL_AppInventor y
What I'm trying to achieve is to have a concrete instance of say...
DAL_AppInventor y and have it inherit the appropriate DAL_AppCommon derived
class. In other words, if I Instantiate DAL_AppInventor yMySql, I would like
it to also have the DAL_AppCommonMy Sql methods/properties.
I know that I can create a factory for each DAL_App* class and then have a
instance member of DAL_AppCommonMy Sql in my DAL_AppInventor yMySql, but I
would rather do this with inheritance if possible. I hope that makes sense.
General pointers/tips/clues VERY welcome.
Thank you for reading,
Steve 7 2925
Hi Steve,
Here are the answers:
1. Unlike c++, you cannot reference a c# file. Reference is done at
the assembly level.
2. It depends. It's better to have it in single assembly by properly
structuring. You can abstract all common data access code to one sigle
file with static/shared method and one file each for you business
objects. By this way, you will get clean segregation.
3. What I believe from your writing is - you are trying to implement
providers for different databases such as MySql, SqlServer,
etc...Instead of reinventing the wheel, I would suggest you to go for
Microsoft Enterprise Library (available for both .NET 1.1 & 2.0 from http://www.microsoft.com/practices ). This library has implentations
for SqlServer and Oracle and you can plug your imlementation for OleDb,
if you have or get from the internet. It's very easy and it reduces
70-80% of your code.
Hope this clears.
Regards,
Hari.
Steve,
Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.
PD
Steve,
Please look at the Enterprise Libraries. I once attempted the same
thing you are and it ended up not working so well. The Enterprise
Libraries will make you happy.
PD
I have no problem with the Enterprise Libraries. They are a time-saver, for
sure. However, without understanding the priniciples involved in designing
them, they are only a temporary convenience.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
<pi****@gmail.c om> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Steve,
Please look at the Enterprise Libraries. I once attempted the same thing you are and it ended up not working so well. The Enterprise Libraries will make you happy.
PD
Hi Steve, 1) Is there a way to share .cs files across several projects? I'm used to this with C++, but in c# it seems that this results in a copy of the files into each project. Is there a way to reference a file from another project? or just a file by itself?
As a C++ programmer, some of this may sound elementary to you, but bear with
me, if you will.
A project is (essentially) a tool for creating an assembly. An assembly can
span multiple DLLs, but usually they do not. A file is a tool for creating a
namespace, a class, or classes, and/or other .Net programming entities. A
solution is a combination of projects, which creates a combination of
assemblies that comprise the various elements of an application, service, or
other solution to a set of requirements.
So, if you want to create a DAL, you don't necessarily want to create 3
different DAL projects. You may only need to create one. In particular, if
you're thinking of sharing a single file between multiple projects, it
sounds for all the world as if you want to create an assembly that can be
used by different solutions. For example, if you are always going to be
working from a single type of data provider, such as the .Net SQL Server
provider, exposed in the System.Data.Sql ... namespaces, you will only need
one assembly with one namespace and one set of classes. On the other hand,
if you want your DAL to work with multiple and various data providers, you
may need a more complex structure, using inheritance, and/or a factory
pattern, such as is illustrated in the Microsoft Enterprise Library (see http://msdn.microsoft.com/library/de...l/EntLib2.asp).
In fact, you can use the Enterprise Library straight out of the box, but I
would recommend studying it, so that you can, as you seem to want to,
improve your own design skills.
2) Typically, do companies use one giant DAL assembly for all applications needing a DAL?
That depends upon the company, and upon the requirements and anticipated
requirements of the company.
3) From what I understand of things, if I wanted to have 3 DAL assemblies all inheriting a common "base DAL" class, I would have a total of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies for each application?
Not necessarily. See my earlier explanation. A single assembly can contain
multiple namespaces and classes. Whether it does or not is pretty much up to
you, and your requirements.
If you have Visual Studio.Net, take a look at the Object Browser. It will
give you a nice picture of the contents of various assemblies, and you can
get a lot of clues from Microsoft's solution as to how you might like to
structure your own.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
We got a sick zebra a hat,
you ultimate tuna.
"Steve" <ss*@sss.com> wrote in message
news:OP******** ******@TK2MSFTN GP15.phx.gbl... Hi all,
I'm designing my DAL layer(s) for our suite of applications and I'm designing myself in circles, it's gotten to the point where each idea just mixes me up more :)
We have 3 loosely related applications and I would like to use an assembly for the DAL in each of them. I have thought of using a single assembly for all of them with several different classes for providers/application specific code, thought of a separate assembly for each application, etc.
I have several questions that I'm hoping will lead to some clarity if I can get them answered and hopefully you can help with some of the answers.
1) Is there a way to share .cs files across several projects? I'm used to this with C++, but in c# it seems that this results in a copy of the files into each project. Is there a way to reference a file from another project? or just a file by itself?
2) Typically, do companies use one giant DAL assembly for all applications needing a DAL?
3) From what I understand of things, if I wanted to have 3 DAL assemblies all inheriting a common "base DAL" class, I would have a total of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies for each application?
4) Check out my little inheritance thing below, question will follow: class DALBase abstract class DAL_AppCommon : DALBase class DAL_AppCommonMy Sql : DAL_AppCommon class DAL_AppCommonSq lServer : DAL_AppCommon
abstract class DAL_AppInventor y : DALBase, DAL_AppCommon class DAL_AppInventor yMySql : DAL_AppInventor y class DAL_AppInventor ySqlServer : DAL_AppInventor y
What I'm trying to achieve is to have a concrete instance of say... DAL_AppInventor y and have it inherit the appropriate DAL_AppCommon derived class. In other words, if I Instantiate DAL_AppInventor yMySql, I would like it to also have the DAL_AppCommonMy Sql methods/properties.
I know that I can create a factory for each DAL_App* class and then have a instance member of DAL_AppCommonMy Sql in my DAL_AppInventor yMySql, but I would rather do this with inheritance if possible. I hope that makes sense.
General pointers/tips/clues VERY welcome.
Thank you for reading, Steve
Thank you for the suggestion, I have been playing with them here and there
or awhile now, very nice solution!
<pi****@gmail.c om> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. . Steve,
Please look at the Enterprise Libraries. I once attempted the same thing you are and it ended up not working so well. The Enterprise Libraries will make you happy.
PD
Wow, great email Kevin, thanks for taking the time to cover that.
Much of what you wrote was already known, but it's always helpful to revisit
things and think about them again.
As far as design skills go, I ran across a library over the weekend that is
utilizing many of the patterns I have read about in my various books. It's
called Composite Application Block. It took about 10 hours of looking over
this code and poking at it before I had my "Ohhhh, I get it. Cool!" moment
:)
Anyway, I appreciate your email, it helped me lay things out a little more
in my head.
Have a good one,
Steve
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l... Hi Steve,
1) Is there a way to share .cs files across several projects? I'm used to this with C++, but in c# it seems that this results in a copy of the files into each project. Is there a way to reference a file from another project? or just a file by itself?
As a C++ programmer, some of this may sound elementary to you, but bear with me, if you will.
A project is (essentially) a tool for creating an assembly. An assembly can span multiple DLLs, but usually they do not. A file is a tool for creating a namespace, a class, or classes, and/or other .Net programming entities. A solution is a combination of projects, which creates a combination of assemblies that comprise the various elements of an application, service, or other solution to a set of requirements.
So, if you want to create a DAL, you don't necessarily want to create 3 different DAL projects. You may only need to create one. In particular, if you're thinking of sharing a single file between multiple projects, it sounds for all the world as if you want to create an assembly that can be used by different solutions. For example, if you are always going to be working from a single type of data provider, such as the .Net SQL Server provider, exposed in the System.Data.Sql ... namespaces, you will only need one assembly with one namespace and one set of classes. On the other hand, if you want your DAL to work with multiple and various data providers, you may need a more complex structure, using inheritance, and/or a factory pattern, such as is illustrated in the Microsoft Enterprise Library (see http://msdn.microsoft.com/library/de...l/EntLib2.asp). In fact, you can use the Enterprise Library straight out of the box, but I would recommend studying it, so that you can, as you seem to want to, improve your own design skills.
2) Typically, do companies use one giant DAL assembly for all applications needing a DAL?
That depends upon the company, and upon the requirements and anticipated requirements of the company.
3) From what I understand of things, if I wanted to have 3 DAL assemblies all inheriting a common "base DAL" class, I would have a total of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies for each application?
Not necessarily. See my earlier explanation. A single assembly can contain multiple namespaces and classes. Whether it does or not is pretty much up to you, and your requirements.
If you have Visual Studio.Net, take a look at the Object Browser. It will give you a nice picture of the contents of various assemblies, and you can get a lot of clues from Microsoft's solution as to how you might like to structure your own.
-- HTH,
Kevin Spencer Microsoft MVP .Net Developer We got a sick zebra a hat, you ultimate tuna.
"Steve" <ss*@sss.com> wrote in message news:OP******** ******@TK2MSFTN GP15.phx.gbl... Hi all,
I'm designing my DAL layer(s) for our suite of applications and I'm designing myself in circles, it's gotten to the point where each idea just mixes me up more :)
We have 3 loosely related applications and I would like to use an assembly for the DAL in each of them. I have thought of using a single assembly for all of them with several different classes for providers/application specific code, thought of a separate assembly for each application, etc.
I have several questions that I'm hoping will lead to some clarity if I can get them answered and hopefully you can help with some of the answers.
1) Is there a way to share .cs files across several projects? I'm used to this with C++, but in c# it seems that this results in a copy of the files into each project. Is there a way to reference a file from another project? or just a file by itself?
2) Typically, do companies use one giant DAL assembly for all applications needing a DAL?
3) From what I understand of things, if I wanted to have 3 DAL assemblies all inheriting a common "base DAL" class, I would have a total of 4 assemblies. Is that correct? 1 base DAL assembly, then 3 more assemblies for each application?
4) Check out my little inheritance thing below, question will follow: class DALBase abstract class DAL_AppCommon : DALBase class DAL_AppCommonMy Sql : DAL_AppCommon class DAL_AppCommonSq lServer : DAL_AppCommon
abstract class DAL_AppInventor y : DALBase, DAL_AppCommon class DAL_AppInventor yMySql : DAL_AppInventor y class DAL_AppInventor ySqlServer : DAL_AppInventor y
What I'm trying to achieve is to have a concrete instance of say... DAL_AppInventor y and have it inherit the appropriate DAL_AppCommon derived class. In other words, if I Instantiate DAL_AppInventor yMySql, I would like it to also have the DAL_AppCommonMy Sql methods/properties.
I know that I can create a factory for each DAL_App* class and then have a instance member of DAL_AppCommonMy Sql in my DAL_AppInventor yMySql, but I would rather do this with inheritance if possible. I hope that makes sense.
General pointers/tips/clues VERY welcome.
Thank you for reading, Steve
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Afaq |
last post by:
Hi,
After adding large number of empty resource files (which will be updated
later), we are not able to compile the project. the following is the output
of the build process. It fails while compiling the Max.UI.Win project with
the following error
Satellite assemblies could not be built because the main project output is
missing.
|
by: JKJ |
last post by:
I'm not an OOP guru, but I would say ". . .not necessarily"
What if the base class and derived classes are internal?
Then the base class has to be within the same assembly to
be inherited from. You may want to create several classes
that are used throughout the assembly, but are not
accessible outside the assembly. . .
If your base class will be inherited across multiple
assemblies and future applications, then I would then
|
by: Donal McWeeney |
last post by:
I have a big Visual Studio class library project from which I create an
assembly. This assembly for example might contain 100 public entry points
(for example custom server controls) and a load of shared back-end library
code that they use.
I now have a need to create 2 new separate small assemblys from the same
code base, with one public entry point in each. For example I want to bundle
2 public server controls, each into their own...
|
by: Saso Zagoranski |
last post by:
hi,
this is not actually a C# problem but since this is the only newsgroup I
follow I decided
to post my question here (please tell me where to post this next time if you
think this post shouldn't be here).
I have two design questions:
1. what is the correct (or best) way to include database queries into the
code if you plan on
|
by: Edward Diener |
last post by:
In Borland's VCL it was possible to divide a component into design time and
run time DLLs. The design time DLL would only be necessary when the
programmer was setting a component's properties or events in the Object
Inspector, the equivalent to the VS .NET Windows form designer. The run-time
DLL would only contain the code necessary at run-time. The design time DLL
referenced the run-time DLL, but not vice-versa. This allowed the run-time...
| |
by: bill |
last post by:
I am migrating a VB6 webclass (IIS application) to a dotNet webforms
project.
There are dozens of designers, class modules, and code modules in this
webclass project, which I will move into VB.NET or CS.NET classes to be
referenced from the web forms project.
I am trying to decide whether to pack all the logic into a single
assembly/dll with numerous classes, or use numerous assemblies with some
classes in each. I guess the answer is...
|
by: keliie |
last post by:
I have a relatively simple (I assume) issue which I am at a complete
loss to address. My issues is: I want to populate fields in my tables
with summary data from the same table. Let me explain:
tblItemDetails (contains data on food products purchased)
Item_Description_ID (key, source link to tblMenuItemRecipe)
Item_Unit_of_Measure
Item_Location
Item_Type
Item_Category
|
by: illegal.prime |
last post by:
Hi all, I'm getting unexpected results when trying to preload
assemblies into an AppDomain I'm creating. Upon creation of the
AppDomain - I attach an AssemblyResolve to both my current AppDomain
and the new AppDomain I create.
I copy all the assemblies/dlls into a new directory and then try
loading them all into the new AppDomain using the following:
private void LoadAssembliesFromDirectory(AppDomain appDomain, string
directory)
|
by: Ken Fine |
last post by:
I've been living with a frustrating issue with VS.NET for some months now
and I need to figure out what the problem is. Hopefully someone has run into
the same issue and can suggest a fix. I suspect some permissions problem.
I'm running VS.NET 2008 in Vista. Symptoms and observations:
* ASP.NET's native ImageMap and Image controls work just fine and provide a
design-time preview of images that are referenced via the ImageUrl property
*...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |