Frustrated...

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 16-Jun-2004 23:35:56   

Here's the situation.. someone please help before my brain explodes...

  1. I am using the SelfServicing classes.

  2. I have TWO different populated <name>EntityCollections.

  3. I use those entity collections to in various parts of the asp.net webform I'm working on.

  4. In addition to being able to use those EntityCollections, I need to be able to convert both of the entity collections to DataTables to pass to aspNetEmail.

I know I can use GetMultiAsDataTable, but that requires another trip to the database and it would be too difficult to keep the DataTables and the EntityCollections synchronized.

I simply do not understand why I can't just export the EntityCollection to a datatable.

The alternative is to figure out how to pass an EntityCollection or a TypedView to aspNetEmail.

Here's a bit of documentation from aspNetEmail for the function I need to call.

SendMailMerge will send a mass amount of emails using a DataSet as a source of Mail Merge Data. Under the covers, SendMailMerge( DataSet MailMergeDataSet ) actually takes the first DataTable of the MailMergeDataSet and calls SendMailMerge( DataTable MailMergeData ).

Overload List SendMailMerge() will send out a list of emails, combining the Subject and Body with data from a DataReader. The SendMailMerge(IDataReader MailMergeReader), actually converts the DataReader to a DataTable and then calls SendMailMerge( DataTable MailMergeData).

public bool SendMailMerge(IDataReader); SendMailMerge() will send out a list of emails, combining the Subject and Body with data from a DataReader. The SendMailMerge(IDataReader MailMergeReader), actually converts the DataReader to a DataTable and then calls SendMailMerge( DataTable MailMergeData).

public bool SendMailMerge(IDataReader,int,int); SendMailMerge will send a mass amount of emails using a DataSet as a source of Mail Merge Data. Under the covers, SendMailMerge( DataSet MailMergeDataSet ) actually takes the first DataTable of the MailMergeDataSet and calls SendMailMerge( DataTable MailMergeData ).

public bool SendMailMerge(DataSet); SendMailMerge will send a mass amount of emails using a DataSet as a source of Mail Merge Data. Under the covers, SendMailMerge( DataSet MailMergeDataSet ) actually takes the first DataTable of the MailMergeDataSet and calls SendMailMerge( DataTable MailMergeData ).

public bool SendMailMerge(DataSet,int,int); SendMailMerge will send a mass amount of emails using a DataTable as a source of Mail Merge Data.

public bool SendMailMerge(DataTable); SendMailMerge will send a mass amount of emails using a DataTable as a source of Mail Merge Data.

public bool SendMailMerge(DataTable,int,int);

Trig
User
Posts: 96
Joined: 09-Jun-2004
# Posted on: 17-Jun-2004 00:28:45   

Seems kinda silly that they don't allow you to pass an IList or something...

You could always try just writing a function that accepts an object of type EntityCollectionBase, use the Items property to get an IList, iterate through casting them as an EntityBase (though the late-bind may be costly depending on the size of the table), grab the Fields from the first entity, create your columns for your DataTable from the fields collection, then add a row to the datatable for each entity. There may be a better algorithm than that, but I'm not aware of one.

alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 17-Jun-2004 06:30:16   

Trig wrote:

Seems kinda silly that they don't allow you to pass an IList or something...

You could always try just writing a function that accepts an object of type EntityCollectionBase, use the Items property to get an IList, iterate through casting them as an EntityBase (though the late-bind may be costly depending on the size of the table), grab the Fields from the first entity, create your columns for your DataTable from the fields collection, then add a row to the datatable for each entity. There may be a better algorithm than that, but I'm not aware of one.

If I could only figure out how to get the collection of fields! I just don't think I'm looking in the right place for that one.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 17-Jun-2004 08:45:05   

You can fetch a collection as a datatable, use GetMultiAsDataTable() method (is a static/shared method of every entitycollection class)

The collection of fields of an entity is available through the 'Fields' property of the entity.

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 27-Nov-2004 15:56:49   

Otis wrote:

You can fetch a collection as a datatable, use GetMultiAsDataTable() method (is a static/shared method of every entitycollection class)

Is there an equivalent for Adapter?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39752
Joined: 17-Aug-2003
# Posted on: 27-Nov-2004 16:31:30   

Marcus wrote:

Otis wrote:

You can fetch a collection as a datatable, use GetMultiAsDataTable() method (is a static/shared method of every entitycollection class)

Is there an equivalent for Adapter?

Yes, adapter.FetchTypedList();

CustomerEntity c = new CustomerEntity(); DataTable customers = new DataTable(); adapter.FetchTypedList(c.Fields, customers, null);

Frans Bouma | Lead developer LLBLGen Pro
Marcus avatar
Marcus
User
Posts: 747
Joined: 23-Apr-2004
# Posted on: 27-Nov-2004 16:37:20   

Thanks.