Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / October 2007

Tip: Looking for answers? Try searching our database.

Does ORM tools work with datagrids or data bindings?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
AliRezaGoogle - 05 Oct 2007 07:50 GMT
Hi
As I know ORM tools encapsulate table rows in objects. In other words
we do not see rows or columns, instead we see objects with properties.
But there are some GUI components that work with dataTables and
dataRows. As an example a datagrid. A datagrid needs a dataSet or
dataTable to show it's content. However my question is about these
components. Working with ORM tools (like NHibernate) how can I feed
objects (which are managed by ORM tool) to a datagrid? How can I even
bind them to a textbox?
If you give me an article about this matter, I will be very thankfull.

Regards
Jon Skeet [C# MVP] - 05 Oct 2007 08:21 GMT
> As I know ORM tools encapsulate table rows in objects. In other words
> we do not see rows or columns, instead we see objects with properties.
[quoted text clipped - 5 lines]
> bind them to a textbox?
> If you give me an article about this matter, I will be very thankfull.

No, DataGrids don't require DataTables. They can use plain lists etc.

I can't say I've done much data binding, but I'd certainly expect it
to work with entities. Note that WPF data binding is significantly
different to Windows Forms databinding, I believe. Not sure how
ASP.NET fits in :)

Jon
Marc Gravell - 05 Oct 2007 10:34 GMT
> No, DataGrids don't require DataTables. They can use plain lists etc.

Indeed. There are a range of common interfaces etc that any
implementation can support, both for collections (IList [with typed
indexer], IListSource, IBindingList, IBindingListView, ITypedList) and
entities (ICustomTypeDescriptor, TypeDescriptionProvider).

But as Jon says - even a simple array / List<T>, ArrayList will
satisfy the most basic binding requirement (IList). For more complex
scenarios there is BindingList<T>. I have created full implementations
of bindable entities / collections with dynamic properties (alon a
property-bag model), and although lengthy, it isn't all that complex.

Note that for binding purposes, PropertyDescriptor (via
TypeDescriptor.GetProperties) rules - and the framework automatically
provides a reflection-based implementation of this, so you get the
class properties. DataTable / DataRow provide an *alternative* model,
but this is, when you think about it, the exception - not the other
way around.

But if you have a specific question, let me know; I've done *lots* in
this area!

Marc
Frans Bouma [C# MVP] - 05 Oct 2007 10:37 GMT
> As I know ORM tools encapsulate table rows in objects. In other words
> we do not see rows or columns, instead we see objects with properties.
[quoted text clipped - 5 lines]
> bind them to a textbox?
> If you give me an article about this matter, I will be very thankfull.

    A grid doesn't need a datatable, if it does the grid is seriously bad
and I'd get one from a competitor.

    Most O/R mappers embed databinding interfaces in the entity classes,
either through code generation or at runtime through subclassing.
(ITypedList, IBindingList, IListSource, INotifyPropertyChanged... )

    We for example implement all databinding interfaces in our entities
and binding them to a control is therefore easy, both at design time
and at runtime, be it an empty collection (so you still get columns to
appear in a grid) or a filled collection, entity etc.

        FB

Signature

------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Ignacio Machin ( .NET/ C# MVP ) - 05 Oct 2007 21:13 GMT
Hi,

> Hi
> As I know ORM tools encapsulate table rows in objects. In other words
[quoted text clipped - 6 lines]
> bind them to a textbox?
> If you give me an article about this matter, I will be very thankfull.

Take a look at Subsonic also, I'm been using it recently and I found it
very useful

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.