c#:only put "using blah.blah.blah" once instead of every page?

Discussion in 'ASP .Net' started by evolve, Oct 30, 2003.

  1. evolve

    evolve Guest

    (in c#) does anyone know a way of having the "using" declaration just the
    once

    for example

    in my website i keep having to put
    using System.Data.SqlClient;

    using System.Data;

    using System.Configuration;





    just so that i can get something out of the database

    surely there is a way of having a bunch of global declarations?


    --
    #-)
     
    evolve, Oct 30, 2003
    #1
    1. Advertising

  2. evolve

    Eric Cadwell Guest

    Sure - just put all your classes in the same file.

    -Eric
     
    Eric Cadwell, Oct 30, 2003
    #2
    1. Advertising

  3. evolve

    William Ryan Guest

    Evolve:

    If you are sticking System.Data.SqlClient over and over in your website,
    that's more a function of your design than an inconvenience forced at the
    behest of Visual Studio. Here's why I say that....

    Let's say that you break up your project into presentation layer, a business
    layer (which may iself be composed of muliple components) and a data access
    layer. Ultimately at the back end you have a database that hosts its own
    potential for logic.

    The only way that you need to keep using libraries of Data in the
    presentation layer is if you data functionality is tightly coupled with it.
    You could easily declare a Datatable for instance, and let your DataLayer
    pass data to and from it. Never on a form would you need a reference to SQL
    Client or configuration.

    You coudl also grab all of your configuration information non-related to
    dataaccess and load them into Session Variables when the app starts. You
    won't need to reference System.Configuration again (except if one of your
    compnents needs it, but even this would only need to happen once per
    component).

    Now, for things like System.Collections and many such libraries, there
    probably isn't a way to compleletey isolate it in one area b/c you need
    collections all over the place. However, this is a relatively small problem
    if you seperate everything into well grouped components.

    HTH,

    Bill
    "evolve" <NOngnSPAMpeaSPAMrseNO_S__PAMhotmail.com> wrote in message
    news:...
    > (in c#) does anyone know a way of having the "using" declaration just the
    > once
    >
    > for example
    >
    > in my website i keep having to put
    > using System.Data.SqlClient;
    >
    > using System.Data;
    >
    > using System.Configuration;
    >
    >
    >
    >
    >
    > just so that i can get something out of the database
    >
    > surely there is a way of having a bunch of global declarations?
    >
    >
    > --
    > #-)
    >
    >
     
    William Ryan, Nov 2, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Flip
    Replies:
    5
    Views:
    389
    John Timney \(ASP.NET MVP\)
    Nov 27, 2004
  2. Mufasa
    Replies:
    2
    Views:
    299
    Mufasa
    Jun 4, 2007
  3. =?Utf-8?B?SXJ3YW5zeWFo?=
    Replies:
    4
    Views:
    2,473
    =?Utf-8?B?SXJ3YW5zeWFo?=
    Oct 30, 2007
  4. Jules Flynn
    Replies:
    1
    Views:
    158
    Thomas 'PointedEars' Lahn
    May 3, 2004
  5. Gancy
    Replies:
    4
    Views:
    204
    Rasto Levrinc
    Feb 3, 2005
Loading...

Share This Page