Thanks for your reply Daelmo, unfortunatelly not as positive as I was hoping...
Yes I already know about DynamicLists and TypedList, but as said on my previous message I think the amount of work for using a DynamicList it's quite considerable and it is a pain having to use Datatable hardcoded fields and casting each one back to the Entity, wich was one of the reasons of adopting LLBL, to avoid using hardcoded strings in our code.
See below a sample of the same code using Dynamic List:
RelationCollection relations =
new RelationCollection(PlaylistEntity.Relations.TrackSetEntityUsingTrackSetLid)
{
TrackSetEntity.Relations.TrackSetItemEntityUsingTrackSetLid,
TrackSetItemEntity.Relations.TrackEntityUsingTrackLid
};
PredicateExpression filter = new PredicateExpression(PlaylistFields.Id== 1);
ResultsetFields fields = new ResultsetFields(6);
fields.DefineField(TrackFields.Title, 0);
fields.DefineField(TrackFields.ArtistName, 1);
fields.DefineField(TrackFields.ReleaseName, 2);
fields.DefineField(TrackFields.Filename, 3);
fields.DefineField(TrackFields.Filesize, 4);
fields.DefineField(TrackFields.DurationSecs, 5);
DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, null, filter, relations, true, null, null, 0, 0);
TrackCollection tracks = new TrackCollection();
foreach (DataRow row in dynamicList.Rows)
{
TrackEntity trackDal = new TrackEntity();
trackDal.Title = row["Title"].ToString();
trackDal.ArtistName = row["ArtistName"].ToString();
trackDal.ReleaseName = row["ReleaseName"].ToString();
trackDal.Filename = row["Filename"].ToString();
trackDal.Filesize = (int?) row["Filesize"];
trackDal.DurationSecs = (int?) row["DurationSecs"];
tracks.Add(trackDal);
}
This is the code using a Dynamic list, as you can see its not as simple as using Collection, and much longer than writting a SQL that populates the DataTable.
In case this is the only option, Is it there a way to assign directly all the fields of an Enitity to a ResultsetFields class? in example: ResultsetFields f = Tracks.Fields()
Secondly its a way to automatically assign a DataRow to an Entity?
Even If I define a TypedList I'll have to do field assignation one by one right?
I'll much appreciate your expertise on this.
Many Thanks