How to store C# objects in DB

G

Guest

I want to store objects that i create programmatically in C#, like in J2EE
(which is callad i think relational mapping or sometihng like this). I want
to create objects that i use for my enterprise applications and store them in
database after execution. And I want the columns and rows related to my
objects to be created and filled automatically.

How can i do that. Thanks?
 
M

Markus Stoeger

basulasz said:
I want to store objects that i create programmatically in C#, like in J2EE
(which is callad i think relational mapping or sometihng like this). I want
to create objects that i use for my enterprise applications and store them in
database after execution. And I want the columns and rows related to my
objects to be created and filled automatically.

How can i do that. Thanks?

There is nothing for that in the .NET framework. You'll need an object
database (look that up on google or wikipedia, there are quite a few
products for .net). I tried the ones from www.db4o.com and www.versant.com.

hth,
Max
 
J

James Jenkins

Markus Stoeger said:
There is nothing for that in the .NET framework. You'll need an object
database (look that up on google or wikipedia, there are quite a few
products for .net). I tried the ones from www.db4o.com and
www.versant.com.

hth,
Max

Hi, In Access you can use the OLE OBJECT type - I don't use SQL Server - but
sureely it has some equivalant ?

James
 
M

Markus Stoeger

James said:
Hi, In Access you can use the OLE OBJECT type - I don't use SQL Server - but
sureely it has some equivalant ?

How'd you store a C# object (instance of a class) in an OLE Object field
in Access? I could be wrong (or have misunderstood the OP), but I think
these are two completely different things.

Max
 
F

Frans Bouma [C# MVP]

Markus said:
How'd you store a C# object (instance of a class) in an OLE Object
field in Access? I could be wrong (or have misunderstood the OP), but
I think these are two completely different things.

serialize to memstream, read the bytes, store in the blob field. to
use it: read record, place bytes in memstream, deserialize.

FB

ps: versant's .net o/r mapper is now a separate company.

--
 
M

Mahesh Devjibhai Dhola [MVP]

May this helps you,
- Serialize your object at run-time using binary formatter into byte stream
- Store the binary data into sql server database as BLOB like how you store
images etc as binary data
- On extraction, get the binary data stream as byte[] and deseializer it to
get actual object

Or You may want to use the way given in the following link,
http://www.codeproject.com/cs/database/persistedobject.asp

HTH,
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

In addition take a look at NHibernate
http://wiki.nhibernate.org/display/NH/Home


cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation



Mahesh Devjibhai Dhola said:
May this helps you,
- Serialize your object at run-time using binary formatter into byte
stream
- Store the binary data into sql server database as BLOB like how you
store
images etc as binary data
- On extraction, get the binary data stream as byte[] and deseializer it
to
get actual object

Or You may want to use the way given in the following link,
http://www.codeproject.com/cs/database/persistedobject.asp

HTH,
basulasz said:
I want to store objects that i create programmatically in C#, like in
J2EE
(which is callad i think relational mapping or sometihng like this). I want
to create objects that i use for my enterprise applications and store
them in
database after execution. And I want the columns and rows related to my
objects to be created and filled automatically.

How can i do that. Thanks?
 
G

Guest

Thanks a lot. Is Visual Studio 2005, or in other words .NET 2.0 supports
relational object mapping by default? Or can we do that by your instructions
by myself?

Thanks for help...

Mahesh Devjibhai Dhola said:
May this helps you,
- Serialize your object at run-time using binary formatter into byte stream
- Store the binary data into sql server database as BLOB like how you store
images etc as binary data
- On extraction, get the binary data stream as byte[] and deseializer it to
get actual object

Or You may want to use the way given in the following link,
http://www.codeproject.com/cs/database/persistedobject.asp

HTH,
basulasz said:
I want to store objects that i create programmatically in C#, like in J2EE
(which is callad i think relational mapping or sometihng like this). I want
to create objects that i use for my enterprise applications and store them in
database after execution. And I want the columns and rows related to my
objects to be created and filled automatically.

How can i do that. Thanks?
 
M

Markus Stoeger

basulasz said:
Thanks a lot. Is Visual Studio 2005, or in other words .NET 2.0 supports
relational object mapping by default?

not that I know of.
Or can we do that by your instructions by myself?

just wondering... do you need to run queries on the stored objects (like
retrieving all objects that have a field set to a certain value) or do
you simply want to store them so they can later be restored?

in the later case serializing the objects (using the BinaryFormatter or
similar) should be fine. If you need to run queries on the objects you
should choose something that does real o/r mapping for you.

Max
 
G

Guest

Actually I want to use instances of my classes that i have stored. For a
product category i want to store properties of products. For example i have a
notebook category and hundreds of notebook items with different properties. I
want to store the data about them in db as persisted objects. I want to do
the task that "hibernate" do in J2EE (Or NHibernate in .NET) by myself.
 
F

Frans Bouma [C# MVP]

basulasz said:
Thanks a lot. Is Visual Studio 2005, or in other words .NET 2.0
supports relational object mapping by default? Or can we do that by
your instructions by myself?

There's no build in O/R mapper in .NET 2.0 / VS.NET 2005. You have to
use a 3rd party application for that, like LLBLGen Pro
(http://www.llblgen.com )

You can try yourself of course, however as it took me 3 years of 10
hours a day, 7 days a week, to write mine, I don't think it will be
feasable for anyone to 'do that for their current project'.

FB
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Thanks for help...

Mahesh Devjibhai Dhola said:
May this helps you,
- Serialize your object at run-time using binary formatter into
byte stream - Store the binary data into sql server database as
BLOB like how you store images etc as binary data
- On extraction, get the binary data stream as byte[] and
deseializer it to get actual object

Or You may want to use the way given in the following link,
http://www.codeproject.com/cs/database/persistedobject.asp

HTH,
basulasz said:
I want to store objects that i create programmatically in C#,
like in J2EE (which is callad i think relational mapping or
sometihng like this). I want
to create objects that i use for my enterprise applications and
store them in
database after execution. And I want the columns and rows related
to my objects to be created and filled automatically.

How can i do that. Thanks?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top