|
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
|
|
|
|
|
Nick Parker wrote:
I am not sure if this will work Paul, but it is worth a shot. Could you return you value as an out parameter?
Good idea, will give that a bash, thanks.
Nick Parker wrote:
What is the problem with reconnecting to the DB?
The code that returns the Columns array is in a SQLDMO helper class I made. I could leave the connection open but then I would have to make sure the caller remembers to close the connection, not very elegant or helpful at all. Also the caller may only act on the returned Columns array many minutes later, in which case I don't want that SQLDMO server connection sitting open all the time.
The good old Open Late, Release Early idea
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:
The code that returns the Columns array is in a SQLDMO helper class I made. I could leave the connection open but then I would have to make sure the caller remembers to close the connection, not very elegant or helpful at all.
True, so why don't you just close the connection once you have receive the data in a dataset, since you said your not sure when the caller will work with the returning dataset and you have already written a helper class why not just do the clean up inside the function and close the connection.
***
If nothing I wrote above made any sense, don't blame yourself. I have had my head stuck in writing a binary tree for the last two hours, yuck.
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
Nick Parker wrote:
True, so why don't you just close the connection once you have receive the data in a dataset, since you said your not sure when the caller will work with the returning dataset and you have already written a helper class why not just do the clean up inside the function and close the connection
LOL no wonder I was getting confused. I was not thinking of using the DataSet (or any ADO.NET) at all. I was hopping the SQLDMO Columns collection could work disconnected, but alas no.
I am going to go the DataSet route now thanks to your and .S.Rod.s advice
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
Yes, that's simple. You can't read a query result on a disconnected database.
That's why ADO.NET introduces datasets. Fill the dataset, then you can disconnect from sqlserver if you like.
|
|
|
|
|
.S.Rod. wrote:
Yes, that's simple. You can't read a query result on a disconnected database.
That's why ADO.NET introduces datasets. Fill the dataset, then you can disconnect from sqlserver if you like.
Maybe I really have the wrong end of the stick but...
The connection and all other database bits are using SQLDMO and AFAIK it does not go through ADO.NET in anyway, right?
Also you are right in that even with SQLDMO once cannot return any query on a disconnected database. What I did there was before the return I created a new Columns var, passed the Columns array from the still connected connection, then disconnected and returned the new Columns var.
At first actually I thought that would get around the whole problem, but I think it was still a reference and not a value and so the error persisted.
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:
The connection and all other database bits are using SQLDMO and AFAIK it does not go through ADO.NET in anyway, right?
Right.
That's why I have said that's up to you to use a ADO.NET dataset as a container for the query result. This requires a few lines of code from you, to fill the dataset with a COPY of the pointed query result. Indeed, there is no direct support for this using sqldmo.
I am talking about a dataset since it's a natural way of storing data with .NET, even though you could just have arrays of strings if you liked.
Of course, the usefulness of sqldmo is questionable, since ADO.NET provides the .NET SQLServer data provider, which does the same job than sqldmo.
Paul Watson wrote:
What I did there was before the return I created a new Columns var, passed the Columns array from the still connected connection, then disconnected and returned the new Columns var.
accessing query results requires a connection anyway. Creating new columns just adds references to objects whose target content vanishes as soon as the disconnection happens. Hence the GPF.
|
|
|
|
|
.S.Rod. wrote:
That's why I have said that's up to you to use a ADO.NET dataset as a container for the query result.
OIC what you are saying.
Thanks man, that makes sense. I still have to get into the whole DataSet way of thinking
.S.Rod. wrote:
Of course, the usefulness of sqldmo is questionable, since ADO.NET provides the .NET SQLServer data provider, which does the same job than sqldmo.
Serious? I will look into that then. Would far rather use ADO.NET to get the structure of a SQL Server and it's databases than having to do COM interop on SQLDMO. Hopefully ADO.NET can provide a list of registered SQL servers as well, like SQLDMO does.
Thanks for the help
Paul Watson Bluegrass Cape Town, South Africa NOPcode wrote:
...but in America, you're not allowed to thrust, moan or see anything...
|
|
|
|