PC Review


Reply
Thread Tools Rate Thread

How to bind an object to a table

 
 
bumperman_jc@hotmail.com
Guest
Posts: n/a
 
      30th Dec 2005
Hi,

I am new to .net. I think .NET provides what I need, but I don't
know how to implement it.

What I need is simply associating an object with a database
table. I would like to load "objects" from table, and I would like to
modify or delete objects, without dealing with database in anywhere. In
other words; I do not want to write SQL query for any of those
operations. Let me give you an example (in C++/CLI):

ref class MessageBase abstract
{
String^ m_strFrom;
String^ m_strBody;
String^ m_strSubject;
DateTime m_dtRecSent;
DateTime m_dtReplied;
DateTime m_dtForwarded;
MessageTypes m_mtType;
public:
property String^ From { String^ get(); void set(String^); }
property String^ Body { String^ get(); void set(String^); }
property String^ Subject { String^ get(); void set(String^); }
property DateTime ReceivedDate { DateTime get(); void
set(DateTime); }
property DateTime RepliedDate { DateTime get(); void
set(DateTime); }
property DateTime Forwarded { DateTime get(); void set(DateTime);
}
property DateTime SentDate { DateTime get(); void set(DateTime); }
property MessageTypes MessageType { MessageType get(); void
set(MessageTypes); }
};

I have got a table to store this information. I would like to
load "messages" from table at startup, through a factory (another
recommendation?). I have prepared a typed dataset, too, but I couldn't
associate it with this class. What I have done previously in C++ was a
simple adapter. Adapter was acting like a "message object" to the
application itself, any changes in the object automatically goes
database, too. As far as I have heard, after associating this class
with a table, I will not write any SQL statement.

I would be very happy, if you could enlighten me about this type
of association. I am using .NET Framework 2.0 (of course, since I am
using C++/CLI) and I do not have a performance concern with this
operation (I have heard that this type of association of an object with
a dataset is far slower than SqlDataReader way). Database is SQLite, I
am using ADO.NET class library to access database from .NET (I have
native library as well).

Thanks!
Jason

 
Reply With Quote
 
 
 
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      30th Dec 2005
Bumperman,

There are hundreds of types of tables in Net, I assume now that you mean a
database table.

An object is the rawest part of Net. In fact the base class for all other
types. Not really the one for binding. It has not any property that you can
bind.

http://msdn.microsoft.com/library/de...mberstopic.asp

However I assume that you mean an from Object inherited ObjectType. From
that you can bind all properties if the mechanisme is made in the consuming
type.

>I will not write any SQL statement.


Do you mean write explicitly and implicitely. Than it is impossible. .Net
and SQL are working thight together where Transact SQL is used.

> I would be very happy, if you could enlighten me about this type
> of association. I am using .NET Framework 2.0 (of course, since I am
> using C++/CLI) and I do not have a performance concern with this
> operation (I have heard that this type of association of an object with
> a dataset is far slower than SqlDataReader way). Database is SQLite, I
> am using ADO.NET class library to access database from .NET (I have
> native library as well).


The SQLDataReader is fairly quicker than using the SQLDataAdapter, which is
in fact a class holding a lot of methods to create, update, remove, select
dataobjects for you (datatable/dataviews, datasets, datarows). Those
dataobjects and the dataadapter have all kind of methods build in. One of
those methods in the dataadapter is using is the datareader.

I hope this gives some ideas

Cor



 
Reply With Quote
 
Jason
Guest
Posts: n/a
 
      2nd Jan 2006
"Cor Ligthert [MVP]" wrote:
>Bumperman,
>
>There are hundreds of types of tables in Net, I assume now that you

mean a
>database table.
>
>An object is the rawest part of Net. In fact the base class for all

other
>types. Not really the one for binding. It has not any property that you

can
>bind.
>
>http://msdn.microsoft.com/library/de...y/en-us/cpref/

html/frlrfsystemobjectmemberstopic.asp
>
>However I assume that you mean an from Object inherited ObjectType.

From
>that you can bind all properties if the mechanisme is made in the

consuming
>type.
>
>>I will not write any SQL statement.

>
>Do you mean write explicitly and implicitely. Than it is impossible.

..Net
>and SQL are working thight together where Transact SQL is used.
>
>> I would be very happy, if you could enlighten me about this type
>> of association. I am using .NET Framework 2.0 (of course, since I am
>> using C++/CLI) and I do not have a performance concern with this
>> operation (I have heard that this type of association of an object

with
>> a dataset is far slower than SqlDataReader way). Database is SQLite,

I
>> am using ADO.NET class library to access database from .NET (I have
>> native library as well).

>
>The SQLDataReader is fairly quicker than using the SQLDataAdapter,

which is
>in fact a class holding a lot of methods to create, update, remove,

select
>dataobjects for you (datatable/dataviews, datasets, datarows). Those
>dataobjects and the dataadapter have all kind of methods build in. One

of
>those methods in the dataadapter is using is the datareader.
>
>I hope this gives some ideas
>
>Cor
>
>
>


Cor,

thank you for your reply.

> I assume now that you mean a
> database table.


Yes.

> An object is the rawest part of Net. In fact the base class for all >

other
> types. Not really the one for binding. It has not any property that
> you can bind.


Either you misunderstood my concern, or, I have failed to chose the
right words. "How to bind an object to a table", doesn't mean type of
object is System.Object (look closer, System."O"bject, capital letter).
Besides this title, I have provided a sample class, which is a "type" of
an "object" (meaning in OOP, not in "C#") that I want to bind to table.
As you can see, it's got properties. By other means, it doesn't mean
anything whether C# uses "object" type for CTS type System.Object, which
begins with capital letter. In fact, only in .NET and Java, all
(managed) objects derive from the same class, but in OOP, an "object" is
not a System.Object, nor it is what C# and its programmers understand
from "object". "class" keyword defines a type. When you instantiate a
type of T, declared with "class", it becomes an "object of type T", and
it's got nothing to do with System.Object. In C++, we have bare "class"
keyword that declares a "native" class and it doesn't necessarily derive
from anything. I hope we are clear at this point, and you've refreshed
"what 'object' word means in OOP".

I am not unfamiliar with C#, I am not unfamiliar with .NET, I am neither
a student nor a 5 years experienced software developer. I know a couple
of ways to do this, typed dataset or NHibernate, or former Object Spaces
(LinQ?). NHibernate does what I need, but NHibernate is complicated,
error prone, takes a lot of time. I need a "typed dataset like"
solution.

>Do you mean write explicitly and implicitely. Than it is
> impossible. .Net
>and SQL are working thight together where Transact SQL is used.


I do not want to write any SQL statement "explicitly". How can I write
SQL statements implicitly? If they are "implicit", doesn't it mean they
are not written by me? In .NET, you can retrieve data from a dataset
without writing even a single line of SQL statement(ReadXml, WriteXml?).

The point is; something like NHibernate, but simpler and preferably
integrated to IDE. Do you know/have a solution?

Jason

TLD LY is Libya, (just in case you may wonder "what the...") though, I
am not related to Libya.

--
Sent via .NET Newsgroups
http://www.dotnetnewsgroups.com
 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      2nd Jan 2006
Jason,

I think that there is nothing to add to your reply.

Cor


 
Reply With Quote
 
dperiwal@softwaretree.com
Guest
Posts: n/a
 
      10th Jan 2006
Jason,

You may want to check out NJDX, the KISS OR-Mapper for .NET, from
Software Tree. NJDX provides a high-performance, user-friendly, and
practical OR-Mapping solution for seamlessly bridging the gap between
the .NET object model and SQL relational model. By eliminating endless
lines of tedious ADO.NET/OleDB/SQL code, NJDX boosts developer
productivity and reduces maintenance hassles.

Adhering to some well thought-out KISS (Keep It Simple and
Straightforward) principles, NJDX provides smooth integration with
popular databases including Microsoft SQL Server, Oracle, IBM DB2, and
Microsoft Access. NJDX has also been tightly integrated with Visual
Studio .NET IDE and can be used with any CLR-based language including
C#, VB.NET, and J#.

You may get a free evaluation version of NJDX from Software Tree's web
site.

-- Damodar Periwal
===============================
Software Tree, Inc.
Simplify Data Integration
http://www.softwaretree.com

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bind controls to object Chris Zopers Microsoft ASP .NET 5 14th Feb 2008 07:19 AM
Need to bind an object Lloyd Sheen Microsoft VB .NET 0 29th Mar 2007 03:56 PM
Object datasource bind problem Kevin Microsoft ASP .NET 0 26th Aug 2006 10:48 AM
Bind an object to a ListBox Juliano.net Microsoft VC .NET 2 2nd Jun 2006 11:34 PM
Want to Eary Bind Instead of Late Bind Object an IE Object Dick Sutton Microsoft VB .NET 3 23rd May 2006 04:32 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:49 AM.