473,413 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

Can we use static table adapters in highly concurrent web sites?

Hi,

I am trying to make our business logic layer components more efficient. We
use strongly typed datasets and TableAdapters.

Is it a good idea to use a static TableAdpater to share the static instance
among all sessions?

My business logic components are like this:
[DataObject]
public static class AccountBLL
{
private static ProfileTableAdapter m_ProfileTableAdapter = null;
private static ProfileTableAdapter AccountProfileTableAdapter
{
get
{
if (m_ProfileTableAdapter == null)
m_ProfileTableAdapter = new ProfileTableAdapter();

return m_ProfileTableAdapter;
}
}

[DataObjectMethodAttribute(DataObjectMethodType.Sel ect, true)]
public static AppDataSet.ProfileDataTable GetAllProfiles()
{
AppDataSet.ProfileDataTable dt;
dt = AccountProfileTableAdapter.GetData();
return dt;
}
}
Whole sessions within the web application are going to share a single
instance of ProfileTableAdapter because it is static. I am a bit concern in
high concurrent situations. Is it safe?

Any help would be appreciated,
Max


Aug 17 '07 #1
6 2474
its a bad idea. you will need to add locking to your current code so
that only one call can run at a time or it will fail when concurrent
requests happen (connection is use errors).

you can still use static methods, but each method should create and
release its own tableadapter.

-- bruce (sqlwork.com)

Max2006 wrote:
Hi,

I am trying to make our business logic layer components more efficient. We
use strongly typed datasets and TableAdapters.

Is it a good idea to use a static TableAdpater to share the static instance
among all sessions?

My business logic components are like this:
[DataObject]
public static class AccountBLL
{
private static ProfileTableAdapter m_ProfileTableAdapter = null;
private static ProfileTableAdapter AccountProfileTableAdapter
{
get
{
if (m_ProfileTableAdapter == null)
m_ProfileTableAdapter = new ProfileTableAdapter();

return m_ProfileTableAdapter;
}
}

[DataObjectMethodAttribute(DataObjectMethodType.Sel ect, true)]
public static AppDataSet.ProfileDataTable GetAllProfiles()
{
AppDataSet.ProfileDataTable dt;
dt = AccountProfileTableAdapter.GetData();
return dt;
}
}
Whole sessions within the web application are going to share a single
instance of ProfileTableAdapter because it is static. I am a bit concern in
high concurrent situations. Is it safe?

Any help would be appreciated,
Max

Aug 17 '07 #2
"Max2006" <al*******@newsgroup.nospamwrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
Hi,

I am trying to make our business logic layer components more efficient. We
use strongly typed datasets and TableAdapters.
Have you done some profiling that suggests that your TableAdapters are a
significant source of poor performance?

If not, then don't touch them! Never optimize where you _think_ the
performance problem is. Don't solve the wrong problem.

Especially don't touch them by making them static, which means that multiple
requests will be using the same data at the same time.
--
John Saunders [MVP]

Aug 17 '07 #3

Does this means that TableAdapter is not thread safe?
"Max2006" <al*******@newsgroup.nospamwrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
Hi,

I am trying to make our business logic layer components more efficient. We
use strongly typed datasets and TableAdapters.

Is it a good idea to use a static TableAdpater to share the static
instance among all sessions?

My business logic components are like this:
[DataObject]
public static class AccountBLL
{
private static ProfileTableAdapter m_ProfileTableAdapter = null;
private static ProfileTableAdapter AccountProfileTableAdapter
{
get
{
if (m_ProfileTableAdapter == null)
m_ProfileTableAdapter = new ProfileTableAdapter();

return m_ProfileTableAdapter;
}
}

[DataObjectMethodAttribute(DataObjectMethodType.Sel ect, true)]
public static AppDataSet.ProfileDataTable GetAllProfiles()
{
AppDataSet.ProfileDataTable dt;
dt = AccountProfileTableAdapter.GetData();
return dt;
}
}
Whole sessions within the web application are going to share a single
instance of ProfileTableAdapter because it is static. I am a bit concern
in high concurrent situations. Is it safe?

Any help would be appreciated,
Max


Aug 17 '07 #4
"Max2006" <al*******@newsgroup.nospamwrote in message
news:eX**************@TK2MSFTNGP03.phx.gbl...
>
Does this means that TableAdapter is not thread safe?
Of course it's not. Almost nothing _is_ thread safe! You should assume that
any class is ***not*** thread safe unless it tells you otherwise!
--
John Saunders [MVP]

Aug 17 '07 #5
Hi Max,

Yes, as for TableAdapter classes, they're complex classes that may contain
internal fields/members that help perform the data accessing code logic,
this will make the class(its methods) become context sensitive and not
thread-safe. I agree that you should void use shared TableAdapter if
possible.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 20 '07 #6
Hi Max,

Do you have any further question on this? If so, please don't hesitate to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Aug 22 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
5
by: Thomas Matthews | last post by:
Hi, I have three classes: Category Author Publisher Each of these classes stores its information into a database table of <ID, text>. (They are fields that have a foreign key.) There is...
2
by: Åženol Akbulak | last post by:
Hi; I am developing an 3 tiered application. And my user interface is an ASP.NET web application. My methods in BLL only uses own parameters and DAL. Now my methods are not static. I heard that...
0
by: Dentharg | last post by:
Hi! I have this exception while getting the data from table adapter. I know that the possible solution is...
1
by: Bruce HS | last post by:
I'm using VS2005, VB, WinForms I’ve developed forms using those nice wizards Microsoft provides. However, I’m running into a couple of complications trying to work with the resulting Table...
6
by: kode4u | last post by:
How to use python get my windows box's ip setting type? Dynamic ip, or static ip? If it's static ip, what's the exact value?
12
by: Randy | last post by:
Hi, Trying to pass along a table row delete to the datasource, but I'm crashing. Here is the code: Private Sub btnDeleteIngr_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles...
3
by: wardemon | last post by:
Hi All, I have a aspx page named: ImageProcess.aspx that creates a thumbnail version of an image by passing the ImagePath, width, and height. The ImagePath is taken from a table from a database,...
3
by: RSH | last post by:
If I have a static method that references the HttpContext.Current object is it safe to be in a static method within a class under ASP .Net? I know that static classes are shared by all sessions...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.