Creating An Abstract Class That Will Define All Database Manipulation Methods To Implement

Mar 3, 2010

I am developing a couple of small ASP.NET application and would like to know what pattern. approach do you use in your projects.

My projects involve databases, using Data access and Business logic layers.

The data-access approach that I was using so far is the following(I read in some book and liked it):

For DAL layer:

Creating an abstract class that will define all database manipulation methods to implement.
The abstract class will contain a static "Instance" property, that will load (if instance == null) an instance (Activator.CreateInstance) of the needed type (a class that implements it).

Creating a classes that implement this abstract class, the implementation will be according to the databases (SQL, mySQL and etc) in use.

With this I can create different implementation according to database in use.

For BLL layer:

A class that encapsulates all all retrieved fields , and static methods that will call the DAL classes.

View 3 Replies

Similar Messages:

How To Define Properties And Methods Of Class That Inherit Stream Class

May 15, 2010

here is the code, where i am confused what to write in all the properties and functions of the base class stream?

I want to inherit abstract class Stream, but confused about what to write?


I could'nt understand how to define these Properties,Sub and Functions. How i start?

View 20 Replies

Security :: Not Extending MembershipProvider Class And Putting All This Methods In Some Unique Class And Call Its Methods Then?

Sep 16, 2010

I am beginner in web applications development. I started one little project and host it on source forge "". And I started implementing authentication in this application to learn how it works. From my experience people never use out of the box things so I want to implement this stuff alone (like in real world projects). So some questions:

1) Is there any reason to use membership out of the box? To use database table schema, stored procedures etc. that tool generate for developer. I think that this lower control over code and I decided to implement it my self. I don't know if I am right.

2) Is my approach in this demo project good or bad (if someone have time I like to do just a little code review)? I created database based on business rules. Not using database schema that membership provider require. Extend "MembershipProvider" class to satisfy my needs. Implement queries to database myself.

3) Now, this question is a little wired but I have to ask it. If we make custom Membership Provider and do sql queries alone, implement all MembershipProvider class methods ourselves, and in application use Membership.blabla() why is this approach different from not extending MembershipProvider class and putting all this methods in some unique class and call its methods then? I hope that someone understand what I ask here.

I am sorry for three questions, but I really trying to find the best way to implement this feature in my demo project like it is a real world application.

View 3 Replies

Use Abstract Class And Interface Class?

Jan 29, 2010

When to use Abstract class and when to use Interface class.

View 10 Replies

Recommendations For Abstract Class Vs Interfaces?

Dec 21, 2010

From the following URL i got some doubts about the Recommendations for using Abstract class vs interfaces


1. If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface. { Is there any example for this t ounderstand throughly ?} If you are designing small, concise bits of functionality, use interfaces. If you are designing large functional units, use an abstract class. If you want to provide common, implemented functionality among all implementations of your component, use an abstract class. Abstract classes allow you to partially implement your class, whereas interfaces contain no implementation for any members. { Is there any example for this t ounderstand throughly?

View 3 Replies

C# - Cannot Create Instance Of Abstract Class?

Mar 31, 2010

I am trying to compile the following code and i am getting the error:

Cannot create instance of abstract class .

m_objExcel = new Excel.Application();
m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks;
m_objBook = (Excel._Workbook)(m_objBooks.Add(m_objOpt));
m_objSheets = (Excel.Sheets)m_objBook.Worksheets;
m_objSheet = (Excel._Worksheet)(m_objSheets.get_Item(1));
// Create an array for the headers and add it to cells A1:C1.
object[] objHeaders = {"Order ID", "Amount", "Tax"};
m_objRange = m_objSheet.get_Range("A1", "C1");
m_objRange.Value = objHeaders;
m_objFont = m_objRange.Font;
// Create an array with 3 columns and 100 rows and add it to
// the worksheet starting at cell A2.
object[,] objData = new Object[100,3];
Random rdm = new Random((int)DateTime.Now.Ticks);
double nOrderAmt, nTax;
for(int r=0;r<100;r++)
objData[r,0] = "ORD" + r.ToString("0000");
nOrderAmt = rdm.Next(1000);
objData[r,1] = nOrderAmt.ToString("c");
nTax = nOrderAmt*0.07;
objData[r,2] = nTax.ToString("c");
m_objRange = m_objSheet.get_Range("A2", m_objOpt);
m_objRange = m_objRange.get_Resize(100,3);
m_objRange.Value = objData;
// Save the Workbook and quit Excel.
m_objBook.SaveAs(m_strSampleFolder + "Book2.xls", m_objOpt, m_objOpt,
m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objOpt, m_objOpt, m_objOpt, m_objOpt);
m_objBook.Close(false, m_objOpt, m_objOpt);

View 2 Replies

Use Of Abstract Class In Shopping Portal?

Jul 27, 2010

I just want to know that how can I utilize the concept of Abstract class, virtual class etc. in my shopping cart website. I have read the tutorial out there on internet and I saw some examples too, but those examples are so general that they dosen't fit into real world scenerio like I am searching for a shopping website. Same questions again and again comes to my mind that why to made a class only to give the declaration of methods and property.

View 4 Replies

Cannot Create The Object Of Abstract Class

Apr 22, 2010

We all know that, we cannot create the object of Abstract class.

But why it is so?

I mean, can anyone explain it with real time example?

View 8 Replies

Architecture :: What Is The Function Of Abstract Class

Oct 24, 2010

what is the function of abstract class, why design pattern need to build BLL and DAL

anyone give an example for my reference as I am getting strat to build my web-based project

View 3 Replies

Why Use Reference Of Abstract Class To Create Object

Jul 22, 2010

Why do we use the reference of abstract class (or base class) to create object of it's sub-class. eg: TextWriter is the abstract class for StreamWriter & StreamWriter.

TextWriter writer = new StreamWriter();

why can't we simply use :

StreamWriter writer = new StreamWriter();

View 3 Replies

Architecture :: Singleton Pattern And Abstract Class?

Aug 19, 2010

I know what Singleton Pattern means and Abstract class means.What I wanted to know was how would this apply to real world.Could anyone give me any good example or simple explanation.Say I have a simple website, why would I use any of the above if any.Why would it simplify my architechture.

View 3 Replies

MVC :: Cannot Create An Instance Of The Abstract Class Or Interface?

Dec 12, 2010

Error 1279 Cannot create an instance of the abstract class or interface 'System.Web.Mvc.FileResult'


I am using MVC 2. The same code works in my onather application. I have no idea about this error.

View 2 Replies

Architecture :: Use Of Abstract Class Design In Real Time Projects?

Jul 21, 2010

What is the use of abstract class design in real time projects

and how to use abstract clases and interfaces

and inheritense concepts

like big shoping portals or content managment,blogs etc

View 5 Replies

Creating Objects From C# Class To Use Them In Database Functions?

Nov 25, 2010

I have created class in C# i need to use objects from this class to add them to a databse table.

the information come from textbox go into the object of the class than from this object i want to preform databse function.

View 2 Replies

Forms Data Controls :: Binding Repeater To List (of Abstract Class)?

Feb 18, 2010

I am attempting to bind a Repeater (but it could be a GridView or ListView) to a list of objects. The List's type is an abstract type, which has two different classes derived from it, both with different properties. Because they have different properties, I cannot just have one ItemTemplate. If I bind a control to a property of one type of class and the other type doesn't have it, it throws an error.

Here's where I'm at:

I cannot use <% if (whatever) { %> some stuff <% } else { %> some other stuff <% } %> because I cannot access the databound item to make the choice based on its type. I cannot use the <%# %> syntax, which lets me use the databound information, because you cannot code logic like if...then...else. I cannot (rather not) call a function and return a string with the code because what I want to render is complex and contains further nested databound controls. Has anyone found an ingenious way of doing if it is this type of object, display these controls, else display these other controls?

View 4 Replies

Architecture :: Creating A Separated Class For Database Connection?

Dec 10, 2010

i have the following code:


I was trying to implement as above. How can i call this class from the code behind of my page, and call the methods Open and Close connection ?

How do i instantiate the object ?

View 5 Replies

DataSource Controls :: SQLDataAdapter Postback / Create A Class, DataCommon, To Contain All SQL Data Manipulation Functions?

Apr 22, 2010

I'm trying to create a class, DataCommon, to contain all my SQL Data manipulation functions. I've created a Subroutine called Init that initializes a SQLDataAdapter:


From my other classes I am creating an instance of DataCommon, calling Init, and calling another subroutine in DataCommon that pulls data from SQL and loads the data into my dataset. This part is working great -- no problems at all. I'm loading three different Datatables in the Dataset with no issues.

At this point, I'll perform my various manipulations on the datatables -- add/delete/modify rows -- again with no problems. All of this is creating postbacks...and this is where my problem begins. After I've done all my manipulations to the data and am ready to update my SQL tables, I have to re-initialize my SQLDataAdapter. I thought I could do something like:

But I get the error: Exception inserting Class. Thread was being aborted.

In my initial data load from SQL, each datatable is getting loaded from a single SQL table, so I was hoping to use the autogenerated Update/Insert/Delete statements by the SQLDataAdapter. As a test, as soon as I filled the dataset initially, I added a new row to one of the datatables and used the SQLDataAdapter.Update() method before a postback occurred, and it worked perfectly.

So, with all that being said, I guess my question is, how do I reconnect the table mappings between my SQLDataAdapter and dataset to autogenerate the updates after a postback occurs? I've tried researching this, but I get confused after reading about FillSchema vs TableMappings vs everything else I've read about.

View 2 Replies

C# - How To Create A Generic/parent Type That You Could Send To Methods Without Having To Define An Overload For Each Type

Mar 5, 2011

I'm trying to create a validation layer that will contain methods to validate all my objects (in my Business Objects layer) .. but when I try to reference both the validation and business objects to each other I get a circular dependency error .. so I've decided to create a new layer (BLL) to validate the objects for me and I'll be able to reference both the validation and the object layers.

so I want to build some kind of class/interface -I don't know what fits more- to be like a generic type or a parent type that my method could accept it as a parameter and check for it's Name/ID property. Instead of defining a new method overload for each object type I have

View 1 Replies

Can't Define Class Or Member That Utilizes Dynamic

Mar 4, 2011

I'm using Facebook SDK C# Library in Asp.Net 3.5 Application. When I'm trying to compile the code below give me the errors. As I know dynamic type using in 4.0 framework. So is anyway to rewrite it in order make it work? I have a reference to System.Core 3.5 but it's still not compiling

protected void Page_Load(object sender, EventArgs e)
if (Request.Params.AllKeys.Contains("signed_request"))
var result = FacebookSignedRequest.Parse(FacebookContext.Current.AppSecret, Request.Params["signed_request"]);
dynamic signedRequestValue = result.Data;
this.RegistrationData = signedRequestValue.registration;
protected dynamic RegistrationData { get; set; }

Error 1 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?

Error 2 Cannot define a class or member that utilizes 'dynamic' because the compiler required type 'System.Runtime.CompilerServices.DynamicAttribute' cannot be found. Are you missing a reference to System.Core.dll?

View 1 Replies

Define Class Of Microsoft Visual Web Developer

Sep 7, 2010

i got microsoft visual web developer and do not understand what a class is would.

View 6 Replies

C# - Class Structure With LINQ, Partial Classes, And Abstract Classes

May 17, 2010

I am following the Nerd Dinner tutorial as I'm learning ASP.NET MVC, and I am currently on Step 3: Building the Model. One part of this section discusses how to integrate validation and business rule logic with the model classes. All this makes perfect sense. However, in the case of this source code, the author only validates one class: Dinner.

What I am wondering is, say I have multiple classes that need validation (Dinner, Guest, etc). It doesn't seem smart to me to repeatedly write these two methods in the partial class:


This doesn't "feel" right, but I wanted to check with SO to get opinions of individuals smarter than me on this. I also tested it out, and it seems that the partial keyword on the OnValidate method is causing problems (understandably so). This doesn't seem possible to fix (but I could very well be wrong).

View 1 Replies

Implement All Required Methods?

Feb 13, 2011

Do I need to implement all the required methods on the MembershipProvider and RoleProvider if writing a custom one to use the AuthorizedAttribute in ASP.NET MVC?

There are a few features that I don't want to implement like CreateUser or 'DeleteRole` because they violate the system I will be authorizing/authenticating against.

View 3 Replies

Web Forms :: How To Define OnClick Routine Of A Button When It Is Created In A Class

Aug 16, 2010

in .vb file, in a class i have created a button control, assigned its ID, and other properties.

In code behind file of a aspx page i have created object of that class.Run the page and browser Button control is coming. Now i want to do something in its click event.

But i am confused how to define that one, since presently there is no any button control instantiated.It is getting instantiated at the runtime.So, how to define its click event or any other events ?

View 5 Replies

BareMessage="Cannot Create An Abstract Class."?

Jun 18, 2010

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: Cannot create an abstract class.

Source Error:

Line 150: <providers>
Line 151: <clear/>
Line 152: <add name="NDMSMembershipProvider"
Line 153: </providers>
Line 154: </membership>

Source File: C:DevCSW2srcCSW.Webweb.config Line: 152

View 1 Replies

VS 2010 Implement Section Update Methods?

Mar 8, 2011

how page update methods are normally done in a web page with multiple sections? I have a few web pages containing several sections. Each section contains different controls/values and can be saved/updated at any point. Can this be done without creating multiple save functions for each "save" button click in each section? Can this be done with one save class that accepts any number of different values?

Also, i have some page values that should insert if it does not exist and update if the value already exist. Currently, i have to check the database to see if the value exist before inserting and updating. Is there a better way of doing this in VS 2010?

View 3 Replies

Copyrights 2005-15, All rights reserved