|
behrang Javaaherian wrote:
there is not enough open source complementary classes and sources
Run a search for "csharp" on SourceForge and you'll see that there are many.
Cheers,
Simon
"From now on, if rogue states want to buy weapons of mass destruction, they're going to have to go on eBay," Mr. Bezos said.
|
|
|
|
|
If you compare the number of Java project with C# Projects it is Obvious. Anyway it is not important that how much Open source projects are now lunch. The C# and .NET doesn't have Object Oriented approach for Persistent data and I called for arm.
Behrang
|
|
|
|
|
forgive my ignorance, but do you have some pointers on what is OR Mapping.
I wanted to know more on this.
Cheers
Kannan
|
|
|
|
|
Suppose you want to write an Adress Directory Application. In Object Oriented environment you have a Class called Party. All the information that both companies and persons have goes here. and you have to class Person and Company derived from party that have their own information. in Database you can have two diferrent aproaches:
1. you have a Party table which have all the field that person and company requires then when you have a person , fields which are for company are set to null.
2. you have a Party table contains only common field and another Person and Company tables for storing type dependent information on them ( a one to one relation between party and these two table also required)
in any of these aproaches the object model are the same but the senario in database completely differs and this will influence the code.
OR mapping means mapping between objects in memory and persistence places ( like Relational Database System). We have a object graph in memory and we want to map this object graph into Database and vice versa we have a some database row and want to create Object graph from it!
a good OR mapping completely seperate the Persistecy of objects from the business logics.
Suppose the example agian. if we have a good OR Mapping framework we can simple write the code bellow :
Company comp = Company.getCompany();
comp.Name = "Microsoft";
Person pers = Person.getPerson();
pers.Name = "Bill";
pers.Family = "Gates";
pers.Company = comp;
PersistentLayer.AddForSave(pers);
PersistentLayer.AddForSave(comp);
PersistentLayer.Save();
so the code is not filled with any SELECT or other Sql Commands. All the Sql commands are in one place and PersitentLayer Engine use some logic to create them.
I hope it was useful for you.
Regards
Behrang
|
|
|
|
|
|
Hi leppie,
This is the way that most of the developers do now. this means having some functions in each class for loading from database. but in this the SQL Commands is in all codes and also we have lots of redundant code in each class. Also another problem is with relations. For example a Person may have a property Called Comapany which point to the company which it works! in this way it is hard to figure out this issue. Another problem is that an object may have lots of property which each have Different Persistent places. For example in our current project we are developing an orderprocessing program. The Adress Directory is currently in Lutos notes. so for example we have a Person object the name , family , email adress, etc are comes from LDAP Server in lutos notes. other business dependent properties like Roles which it accepts are come from RDMS.
An OR Mapping Tool use some Descriptor files ( mostly in XML format for describe an object).
Regards
Behrang
|
|
|
|
|
|
For tackle into problem which should delegates all the reffrences into our engine to load from Database. suppose a Person object again it has some properties : (name , family, etc). The key feature here is to capture access to name property and delegate ( means route and have nothing with delegates in C#) into our engine. this is possible in languages like Objective-C ( it is another great programming language from Apple). in C# we should use another way. The way that I used it using Keypath Access instead of Property. means that for example for access name of a person i use person["Name"] instead of person.Name. In this way all the access goes through an indexer function. the indexer function parse the string and find appropiate operation from Descriptor files. if I want to use properties either i should write My own wrapper functions like this
string Name
{
get {return this["Name"];}
set {this["Name"] = value;}
}
I wrote a simple OR Mapping tools in C# but the code is not clean enuogh to understood and it needs refactoring. if anyone wants the code please send an email to me for code.
Regards
Behrang
|
|
|
|
|
|
The Idea i used in my code is like the idea which the EO developer team done in Enterprise Objects. I assumed each table in database have CLASS column. in this class I hold the class of the object which should be instansiated. all the objects are derived from a base class Called Entity. The Entity class is the core class for my framework. I get Entity Objects from another SingleTone class called EntityManager. The code would be like this:
Entity en = EntityManager.getEntity("Party",new EntityKey(123));
this means loading entity which the parent of it is Partey and the primary key is 123 .
The EntityKey is another object. I used this object to be able to have none-numeric primary keys.
The FrameWork First Load the XML File which describe the Party. (Party.XML for example) this Descriptor shows the Primarykey field and also Table name of the Party ( For exmaple pk , Party)
then a Query command for getting the class the sql command is : "SELECT CLASS FROM PARTY WHERE pk=123".
The Query will return For example PERS. the program will create the appropiate class name (Forexample Model.Person) this class should be inherited from Entity. now the Framework loads the person.Xml , find the properties from descriptor and create appropiate SQL Command for loading other information of the Person. The Simple attribute have no problem. The problem is with relations. Suppose a Person have a relation to another Object in another table. The Framework can work in to different way :
Load it when the Parent Object loaded ( Early)
Load when access to it required (Lazy)
the lazy loading is done through proxy objects ( refer to design pattern book to see what is Proxy Object).
Regards
Behrang
|
|
|
|
|
|
|
It is a very good fantastic the Framework would be able to create DDL ( SQL Command for creating tables) file for xml descriptors but the framework is not able to do it.
Regards
Behrang
|
|
|
|
|
I have been doing some looking into OR solutions(open/free & commercial) and found an open source project that is still in the planning stages that looks very promising. So you might want to take a look at it instead of starting another project. From reading some of the discussions it looks like they are going to build something similare to Hibernate.
http://opf.sourceforge.net/[^]
If anybody would like I can post a list of OR mappers for .NET that I have found.
Mike
|
|
|
|
|
thanx Mike,
I have downloaded the opf before. The opf is not design well. Also it has nothing for support Distribution. I worked with lots of OR Mapping tools. The best tool is Cocobase ( $6000 Per developer , Per project !!!!) and the Entriprise Objects (EO)(Part of Web Objects from Apple ) is very good product. so I prefer the same Approach as apple developer's team done in EO.
Regards
Behrang
|
|
|
|
|
Behrang, I am curious about what parts of the design you don't like. I always appreciate others opinions/thoughts on products. I haven't looked at EO, but will do so ...
Thanks for the info!
Mike
|
|
|
|
|
Hello
Anybody know how I would programmatically launch a "file search window" from an application being developed in .net (C# or visual basic). Basically what I want is to be able to click on a button on my application and have a similar result as if I clicked on the "Search->For Files or Folders..." menu item of the windows start menu.
Thanks for any help you can provide.
|
|
|
|
|
Have a look at IShellDispatch set of interfaces.
It has scriptable(IDispatch) methods which you can call from languages like vb6.
From .net you need to add reference to shell32.dll which will be in the system32 folder and this is the code to call the search for files dialog.
<br />
ShellClass obj = new ShellClass();<br />
obj.FindFiles(); <br />
Hope this helps.
Cheers
Kannan
|
|
|
|
|
Thanks a bunch Kannan,
Thats exactly what I wanted, it was almost too easy
AJ
|
|
|
|
|
How do resources work in .NET?
I'm just trying to include a bitmap for an imagelist...
However, MSDN talk either about ".rc" files which somehow I cannot add to my project (or can I?), or about .resx files being "the .NET" way and their cute and politically correct features how to localize your dialog resources and web apps (something I promise to look into once I get those friggin' folder icons into my tree view!)
Is there a Tutorial in MSDN? An article on CP? A merciful soul that gives me some step-by-step-instructions?
Oh, when we're at it... :blush: ...how do I get the "hinstance" i need for Bitmap.FromResource? or can I pass "null" for "me"?
Thanks
If I could find a souvenir / just to prove the world was here [sighist]
|
|
|
|
|
peterchen wrote:
An article on CP? A merciful soul that gives me some step-by-step-instructions?
Yes, JTJ has written a nice article on embedded resources in .NET. Understanding Embedded Resources in Visual Studio .NET[^]
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Hi all
I want to create an ActiveX Control using c# and import it in non .NET application (MFC 6). How can it be done (I dont want a simple class, but visual control)? Generaly, what is the approach of .Net toward ActiveX, can I stil create an ocx file and use it in MFC(6) app?
If Activex is not relevant any more, how can use a .Net (c#) control from MFC app?
It would be greate if u could direct me to some data source about this...
thanks
|
|
|
|
|
I'm a beginner in .NET so take this all with a grain of salt.
An ActiveX control is basically a COM object that produces windows output.
Ergo, you need to construct a COM object in reality - maybe perhaps a COM object that is also a Control.
I noticed in the Articles section there are a couple of articles on COM Interop and creating COM objects out of .NET objects.
-Adrian
|
|
|
|
|
I have the following code which returns a Columns array back to the caller. The code is C# (no really!) with COM interop on the SQLDMO COM object.
SQLDMO._SQLServer sqlserverMain = new SQLDMO.SQLServerClass();
sqlserverMain.Connect(this.ServerName, this.UserName, this.Password);
SQLDMO.Database sqldatabaseCurrent = (SQLDMO.Database)sqlserverMain.Databases.Item
(this.Database, sqlserverMain);
SQLDMO.Table sqltblCurrent = (SQLDMO.Table)sqldatabaseCurrent.Tables.Item
(this.Table,sqlserverMain);
return sqltblCurrent.Columns;
So it creates a SQLDMO server connection, then gets a database, then gets a table and finally gets all the Columns for that table and returns that array.
However there is no sqlserverMain.DisConnect(); because of my problem. Basically if I put in the disconnect code then when I want to use the returned Columns array I get a "This object has been detached from SQLDMO, as the result of a refresh, automatic shutdown, error or App.Quit" error message.
If if leave out the disconnect then it all works fine.
Now my guess is that this is a classic reference vs. value problem with the return array. I am returning a reference rather than the value.
This is probably really, really simple but then how do I return the value and not the reference? I need to disconnect because otherwise I am leaving the connection open and by watching Taskmanager I noticed the app just kept eating memory without releasing every time that specific method was called. With the disconnect (but avoiding the error) the app eats memory and then releases it on disconnect.
ta
Paul Watson Bluegrass Cape Town, South Africa NOPcode wrote:
...but in America, you're not allowed to thrust, moan or see anything...
|
|
|
|
|
Paul Watson wrote:
This is probably really, really simple but then how do I return the value and not the reference?
I am not sure if this will work Paul, but it is worth a shot. Could you return you value as an out parameter? What is the problem with reconnecting to the DB?
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|