Dynamic Data woes [repost]

P

Pete Hurst

Hi,

(Sorry, reposted having configured my alias)

I've been trying to set up my new blog/portfolio site using Dynamic Data. I
haven't got very far.

I *have* managed to get as far as scaffolding all my tables and creating
metadata attributes. Very nice. But this is where all the examples and
tutorials seem to stop.

What I now need to do is heavily customise both the UI and business logic.

What I'm really looking for would be an example *full working website*
created using DD. The downloadable examples I've found are all of the
"simple 2 table website" variety which don't really give me any clues as to
how I can hook in any advanced customisation.

For instance, how can I complete the following workflow:

- A user creates a new record in a scaffolded insert form
- As this record is being saved, I want to create a related record in
another table, if certain conditions are met on the insert record
- If this related record IS created, then I want to also modify some
properties on the record being inserted, including the FK that actually
links the insert record to the new one

The only way I can see to do this in LinqToSQL is by overriding the
SubmitChanges method of DataContext, looking for particular entity types
being inserted, and perform my business logic there. But I really don't see
how that's the best place to do it.

I've also been trying with Dynamic Data Entities. Here it seems I have to
attach to the SavingChanges event of the ObjectContext, but the process here
for determining what type of objects are being updated seems even more
bizarre and arcane.

Am I missing something or is this really the only way of doing things?

Why do the entities not have partial methods like OnInserting and
OnUpdating? (Perhaps with access to the attached Context in case I want to
insert any other records during the save...)

And are there any more complete examples for me to look at?

Thanks in advance,
Pete Hurst
 
M

Mr. Arnold

Pete Hurst said:
Hi,

(Sorry, reposted having configured my alias)

I've been trying to set up my new blog/portfolio site using Dynamic Data.
I
haven't got very far.

I *have* managed to get as far as scaffolding all my tables and creating
metadata attributes. Very nice. But this is where all the examples and
tutorials seem to stop.

What I now need to do is heavily customise both the UI and business logic.

What I'm really looking for would be an example *full working website*
created using DD. The downloadable examples I've found are all of the
"simple 2 table website" variety which don't really give me any clues as
to
how I can hook in any advanced customisation.

For instance, how can I complete the following workflow:

- A user creates a new record in a scaffolded insert form
- As this record is being saved, I want to create a related record in
another table, if certain conditions are met on the insert record
- If this related record IS created, then I want to also modify some
properties on the record being inserted, including the FK that actually
links the insert record to the new one

The only way I can see to do this in LinqToSQL is by overriding the
SubmitChanges method of DataContext, looking for particular entity types
being inserted, and perform my business logic there. But I really don't
see
how that's the best place to do it.

I've also been trying with Dynamic Data Entities. Here it seems I have to
attach to the SavingChanges event of the ObjectContext, but the process
here
for determining what type of objects are being updated seems even more
bizarre and arcane.

Am I missing something or is this really the only way of doing things?

Why do the entities not have partial methods like OnInserting and
OnUpdating? (Perhaps with access to the attached Context in case I want to
insert any other records during the save...)

This is most likely what you need to see are the tutorials where it starts
showing how to use validation, partial class and partial method/function.

Also Link-2-SQL is not going to be supported like the ADO.NET Entity
Framework used by Dynamic Data Entities.

http://www.asp.net/learn/3.5-SP1/
 
A

Allen Chen [MSFT]

Hi Pete,
For instance, how can I complete the following workflow:

- A user creates a new record in a scaffolded insert form
- As this record is being saved, I want to create a related record in
another table, if certain conditions are met on the insert record
- If this related record IS created, then I want to also modify some
properties on the record being inserted, including the FK that actually
links the insert record to the new one

From your description you want to get an entry to hook the inserting event
when using Dynamica Data, right?

If so you can find the Insert.aspx in the "PageTemplates" folder in the
solution explorer window. In the aspx you can find a DetailsView. This is
used to generate the table for inserting. You can add ItemInserting event
handler for the DetailsView and do anything you like there. You can get
more information about current table via the "table" variable.

Please try it and let me know if it works and feel free to ask if you have
additional questions.

Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Pete Hurst

Mr. Arnold said:
This is most likely what you need to see are the tutorials where it
starts showing how to use validation, partial class and partial
method/function.

Thanks for the link, alas they are all videos! Why is a transcript never
posted alongside the videos? I find this happens a *lot* with .NET-related
content, and for me it's quite frustrating having to watch hours of video,
when I could assimilate the information far quicker just by reading the
text. Also I'm not always even able to listen to audio, depending on my work
location. Not to mention, it's an accessibility nightmare. (Obviously, this
isn't directed at you, just to Microsoft in general and to anyone who puts
these screencasts together!)
Also Link-2-SQL is not going to be supported like the ADO.NET Entity
Framework used by Dynamic Data Entities.

In what way is LINQ not being supported? It's a shame, I'd love to be using
EF but so many things about it seem not quite ready for production. For
instance, not being able to use Enum fields like I can with LINQ (and many
other problems that appear to require workarounds).

Pete
 
P

Pete Hurst

Allen Chen said:
From your description you want to get an entry to hook the inserting event
when using Dynamica Data, right?

If so you can find the Insert.aspx in the "PageTemplates" folder in the
solution explorer window. In the aspx you can find a DetailsView. This is
used to generate the table for inserting. You can add ItemInserting event
handler for the DetailsView and do anything you like there. You can get
more information about current table via the "table" variable.

Please try it and let me know if it works and feel free to ask if you have
additional questions.

I'll investigate the templates further - however, the UI layer seems to be
the wrong place to be performing my business logic. I suspect I'll just have
to run with it for now, and hope that future versions of the framework
encourage cleaner separation! Thanks for your pointers.

Pete
 
M

Mr. Arnold

Pete said:
Thanks for the link, alas they are all videos! Why is a transcript never
posted alongside the videos? I find this happens a *lot* with
.NET-related content, and for me it's quite frustrating having to watch
hours of video, when I could assimilate the information far quicker just
by reading the text. Also I'm not always even able to listen to audio,
depending on my work location. Not to mention, it's an accessibility
nightmare. (Obviously, this isn't directed at you, just to Microsoft in
general and to anyone who puts these screencasts together!)


In what way is LINQ not being supported? It's a shame, I'd love to be
using EF but so many things about it seem not quite ready for
production. For instance, not being able to use Enum fields like I can
with LINQ (and many other problems that appear to require workarounds).

Linq-2-SQL supports only MS SQL server while EF supports several
database types.

Linq-2-Entities works well in EF along with Entity SQL, and I don't even
think Enum is supported in nHibernate, another ORM solution that's
widely used, either that supports many database types.

The recommendation is to use is EF.

<http://blogs.msdn.com/adonet/archiv...linq-to-sql-and-linq-to-entities-roadmap.aspx>

In addition, Link-2-SQL is not as versatile as EF, which I am using with
the ASP.NET Data Service technology in the below link and using EF with
WCF Web service with an EF Entity being an implicit WCF contract. EF is
fabulous stuff, and Linq-2-SQL is lagging.

<http://leriksen71.wordpress.com/2009/02/11/adonet-entity-frameworkdata-services-first-impressions/>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top