0

I'm trying to build a web application that let the administrator talk to the database through C# and add new tables and columns to fit his requirements (sort of a very simple database studio) but I'm not trying to just create some spaghetti application.

So I'm trying to figure out how to let those things dynamically (automatically) when he creates a table and use the table to build them :

1- The business objects or entities (the classes, it's objects and properties). 2- The Data access layer (some simple methods that connects to the database and add, update, delete retrieve items (objects)).

Is this possible ? any pointers on how to achieve it ?

EDIT

just opened your link!! .. it's talking about the data bound controls and stuff! .. my question is way more advanced than that!. when you build an N-Layered application you start with the database schema and implementation and it's easy to do programtically then you start building the DAL classes which (add, edit, etc in other words the CRUD operations) in and form this database

what I want to do is to allow the web administrator to choose add the new table through my application and then -dynamically- the application would take the tables names and columns as parameters and create new classes and define within them the CRUD methods that will implement the SQL CRUD operations

then it would also create dynamically the classes and define within them the variables, properties and methods to call and use the DAL methods .. all this based on the table, column names

NOTE : All this happens on the run-time!

Mazen Elkashef
  • 3,430
  • 6
  • 44
  • 72
  • Functionality what you are trying to build is very valid. MS CRM does it out of the box. Point is that whatever you intend to build is not everyday thing and you need to do it by yourself. This is falling in innovation bucket. I too wanted to build something on this line, but it is going to take time...hence parked it. – Pradeep Feb 28 '11 at 05:47
  • @Pradeep, actually I know it's not a walk in the park but I'm investing my time to allow myself in the future to make many projects for my clients in a small time .. I think it's worth it and it's going to be a walk in the park in the future .. but I agree I'm gonna park it for a while! .. I hope you could provide some links or documentation to this MS CRM so I could mark it as an answer .. You was really helpful =) Thank You Pradeep! – Mazen Elkashef Feb 28 '11 at 05:55
  • Posted the link. Hope it helps you. I will also restart my work and let you know if I make any progress. – Pradeep Mar 01 '11 at 18:46

4 Answers4

1

You might want to look into ASP.Net Dynamic Data. It's a RAD tool which very easily gives you CRUD functionality for your entities and more. Check it out.

Bala R
  • 107,317
  • 23
  • 199
  • 210
  • that's gr8 for my DAL I'll take a look on that .. but any ideas on how to dynamically create the BLL (the classes, it's variables and properties) ? ..+1 – Mazen Elkashef Feb 28 '11 at 00:25
0

First, any man trying to create MS Access is doomed to recreate MS Access. Badly.

You are better off using ASP.NET Dynamic Data (as suggested) or ASP.NET MVC Scaffolding. But runtime-generated playforms that actually make decent applications are really pipe dreams. You will need developer time to do anything complex. Or well.

Wyatt Barnett
  • 15,573
  • 3
  • 34
  • 53
  • Wyatt I'm sorry, I don't want to display dynamic data .. I want to build a dynamic architecture .. it's not about the Presentation Layer at all! .. thanks for your effort though :) – Mazen Elkashef Feb 28 '11 at 05:19
0

Sometime back I had also asked similar question on SO. I got only one reply.

Today I was digging some information on MSDN and as I had guessed it, MS CRM entity model works based on metadata. So basically whatever a CRM developer is working against is just metadata, they are not real objects as such. Following is the MSDN link.

Extend MS CRM Metadata and here is the MS CRM 4.0 SDK.

I hope this should get you started.

Update: Recently hit upon Visual Studio LightSwitch. I think this is what we wanted to build. A UI which will pick up table information from DB and then create all CRUD screens. VS LightSwitch is in its Beta1 and has quite a lot of potential. Should be a nice starting point.

Community
  • 1
  • 1
Pradeep
  • 3,258
  • 1
  • 23
  • 36
  • Wow (Y) Thanks Pradeep .. and I would definitely like to hear from you if you restarted on this project. I dunno what's the policy of stackoverflow on sharing emails but if it was fine by you I would like to hear from you about this project! – Mazen Elkashef Mar 01 '11 at 20:24
-1

What you are asking is non-sense. Why? Because the idea behind BLL and n-tier is that you know your data model well, and can create a static class model to represent your data model.

If your data model is dynamic, and changing, then you cannot create a static BLL (which is what a BLL is). What you will have to do dynamically build your queries at run-time. This is not something that any of the traditional methods are designed to handle, so you must do everything yourself.

While it's possible to dynamically generate classes at run-time, this is probably not the approach you want to take, because even if you manage to make your BLL adapt to your dynamic database.. the code that calls the BLL will not know anything about it, thus it will never get called.

This is not a problem you will solve overnight, or by copying any existing solution. You will have to design it from scratch, using low level ADO calls rather than relying on ORM's or any automation.

Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • Thanks Mystere Man. That's true and I know it, but I was trying to let my code have some intelligence to understand the change for me(the admin). this will save some time and effort in the future to have such a flexible system to create dynamic websites. so all I was asking if some one already did it so I could use it or any pointers on how to start .. btw I already found a project that I think applies my idea, I'll search for it and will let you know! thanks for the help =) – Mazen Elkashef Feb 28 '11 at 05:28
  • @Pradeep I dunno the guy but Excuse him! .. and Mystere Man please don't surly advice about something you are not sure about! your knowledge isn't the limit of this world! .. you almost throw me off! – Mazen Elkashef Feb 28 '11 at 05:58
  • @Pradeep - I didn't call the question non-sense, I said what he was asking for was non-sense, as in it didn't make any sense. He was asking for mutually exclusive things. – Erik Funkenbusch Feb 28 '11 at 07:30
  • @IKashef - I am not saying it can't be done, i'm saying that it makes no sense to do it as a traditional n-tiered application. – Erik Funkenbusch Feb 28 '11 at 07:32
  • @Mystere Man, you didn't say the "as a traditional n-tiered application" part. and told you yh It's not a thing that I do everyday .. I'm creating an application to generate a dynamic architecture so I could be able to do more projects in no time and no effort .. so it's kinda once in a life time thing =D! – Mazen Elkashef Feb 28 '11 at 17:36