How could I fill an esCollection from a datatable previously created and loaded? I tried the code below, but it didnt work...Raises me a compilation error.
protected
{
d.Columns.Add(
dataRow[
e.Collection = d;
}
When posting code use our "Code" button rather than copying code in from visual studio. Also, why are you doing this when you can load a collection from the database using any low level method in the base class? If you are getting the data that is in this DataTable from the database then you can definitely load it into your collection through one of the protected Load() methods.
That code just doesn't make sense? The esDataSource doesn't work with raw datatables and that entire set of code can be done on your Collection via AddNew() and simply filling in the properties?
EntitySpaces | Twitter | BLOG | Please honor our Software License
This is alot easier and far less error prone than messing with DataTables ...
protected void EsDataSource6_esSelect(object sender, EntitySpaces.Web.esDataSourceSelectEventArgs e) { EmployeeCollection coll = new EmployeeCollection(); Employee emp = coll.AddNew(); emp.FirstName = "Mike"; e.Collection = coll; }
This might work, however, EntitySpaces is not meant to be used in this fashion, so we cannot spend a lot of cycles on technical support regarding this issue. Officially, this is not supported. This method would go in your Custom class.
public partial class CustomerCollection : esCustomerCollection{ public bool CustomPopulate() { DataTable dt = SomeMethodThatReturnsADatatable(); this.Table = dt; this.PopulateCollection(); }}
The reason we cannot spend a lot of time on this is because the end result is the same as if you would have populated the entity from the public EntitySpaces API. I'm bewildered as to why you want to use this approach? There is also a method called CreateColumnsForBinding() which will create the underlying DataTable for an Entity, but again, I'm confused on your approach.
I give up...I just cant use any of the existing collections for doing this job. I wanted a simple taks, that is, fill a datatable into a escollection (not a custom or a generated collection that was created by MyGeneratio). If I need this, it is for some reason....
Thanks anyway...
Hi
If I'm understanding the question properly I think what is being asked is the following
1) You've created your own class based off esEntityCollection - i.e. this class is manually crafted and has not been generated by MyGeneration so you have an empty class that inherits from esEntityCollection,.
2) You want to fill this collection from a datatable or other source. As the class doesn't include the regular generated entityspaces code you're trying to do this with methods that are defined and implemented in esEntityCollection.
Unfortunately I don't have time to look into this personally but I thought it might help to rephrase the question (if I've understood it correctly) so that someone else may better answer it.
Hope that helps but apologies if I've completely misunderstood
Cheers
Martin
Perfect Martin, now you understood what I meant. Its exactly this, I just needed to use a simple esCollection (the basic one that is there when we provide the esDataSource), feeding it from a datatable. I understand you ES fellows are overcharged on tasks and improvements. Again, sorry for interrupting this, I found a workaround anyway...
Thanks!