Bruce said:
Lets put this way, these r some of the topics I consider not well
resolved in ORM around there
Most O/R frameworks work in a unique way, they have 'mapping' in
common but a lot is solved in various ways.
1) How to deal with joins returning all fields in a single
collection. Consider this join must be created using Dynamic Sql...
You mean, you want orderid, orderdate, customerid and companyname from
order, customer for example ?
first of all, O/R mapping is about entities. So in my example above,
you have the Order entity and the Customer entity. You can manipulate
them through instances of entity classes which are mapped onto the
views or tables which represent the order and customer entity.
If you want to manipulate a resultset from a join, which in theory is
another entity, you probably have a hard time, as you might not have a
PK value for some of the entities. This is also the reason why most
databases don't update multiple tables through a view.
So if I want to fetch thet set I talked about in my example, I can do
so in the O/R mapper I'm lead developer of: LLBLGen Pro (see
signature). I can do that in a typed construct called a typed list,
which is designed in the LLBLGen Pro designer, or I can do that in a
dynamic list which is an untyped datatable. Let's look at an
implementation of the latter. We support two paradigms: persistence
logic in the entities (e.g. myOrder.Save(), called 'Selfservicing'))
and persistence logic in a separate object
(myDataAccessAdapter.SaveEntity(myOrder), called 'Adapter'). My example
below is using the adapter paradigm.
// define the resultset fields, using O/R mapper meta-data so the
// query generator engine can generate proper SQL
ResultsetFields fields = new ResultsetFields(4);
fields.DefineField(OrderFields.OrderId, 0);
fields.DefineField(OrderFields.OrderDate, 1);
fields.DefineField(CustomerFields.CustomerId, 2);
fields.DefineField(CustomerFields.CompanyName, 3);
DataTable results = new DataTable();
// let's fetch all the data for the customers from Germany
// define the filter and the joins
RelationPredicateBucket filter = new RelationPredicateBucket();
filter.Relations.Add(
OrderEntity.Relations.CustomerEntityUsingCustomerId);
filter.PredicateExpression.Add(CustomerFields.Country=="Germany");
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
adapter.FetchTypedList(fields, results, filter);
}
et viola.
of course, if you want to map an entity onto multiple tables through
inheritance, you can do that too.
2) Everytime u call a .Save method, u have to have the records
already in memory, that means u just cant fire an Update;Delete by
using Dynamic Sql...
no, LLBLGen Pro also supports delete and update statements directly on
the db, so you can update / delete a lot of entities at once. You can
use relations, filters, expressions etc. in those qeuries as well.
BTW, how do u map DB fields to properties, by using a XML file I
suppose...
No, not an XML file, through a designer which generates the meta-data
into code.
See for yourself, download the trial
Frans
--
------------------------------------------------------------------------
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#)
------------------------------------------------------------------------