This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi, In the Helpfile for the Dynamic Data example for LightSpeed it says: (mk:@MSITStore:C:\Program%20Files\Mindscape\LightSpeed%202.2\Documentation\LightSpeed.chm::/Help%20Topics/Web%20Tools/DynamicData.html) Remarks How and where do I do that ToStrring() override?
Thans M |
|
|
Create a partial class for the entity. (You can do this manually using Add Class and adding the partial modifier, or if you have a recent nightly build of LightSpeed you can right-click the entity and choose Refactor > Create Partial Class.) You can then implement the override in this partial class. |
|
|
Thanks for you help Ivan, I’ve tried your suggestion but I can’t seem to be able to do what I need. When using ADO .Net Entity Data Model, the ID fields are automatically translated via the FK relationship. I’ve also tried different methods as described in http://www.mindscape.co.nz/staff/jeremy/index.php/2009/03/aspnet-mvc-part1 , http://www.mindscape.co.nz/blog/index.php/2009/06/22/refactoring-in-the-lightspeed-designer and http://www.mindscape.co.nz/forums/Thread.aspx?PostID=3123 Is there a tutorial and/or example(s) on how to get LightSpeed to translate the FK IDs? Thanks in advance |
|
|
Consider the following model: public class Customer : Entity<int> { public class Order : Entity<int> { As you've seen, when you browse Orders in Dynamic Data, the Customer associated with each order will be shown as "[Customer (Id=123, EntityState=Default)]." Suppose you would like the Customer to be displayed using the Name instead. Then you need to add the following to the Customer class: public override string ToString() { If you are handcrafting the Customer class you can put this into the class directly; if you are using the designer you need to put it into a partial class. Now when you fire up the Dynamic Data site and look at an Order, the Customer column will show the customer name instead of the ID string. Note that a many-to-many goes through an intersection table and you would need to override ToString on the intersection type. If this still doesn't work for you, could you zip up your Dynamic Data project and attach it via the Options tab or email it to ivan @ the obvious domain name (please strip out all binaries first), and we can take a look at it. Thanks! |
|
|
Hi Ivan, I'm getting closer with your help! I've managed to get the ID columns correct (I created a partial class for the Many2Many class instead of the other 2 related classed, duh). I've now moved on and I'm trying to get oracle to work. Not sure if you can help with that but I'm getting a: Sys.WebForms.PageRequestManagerServerErrorException: IsolationLevel must be ReadCommitted or Serializable and I'm not sure where to set that when using the designer in a Dynamic Data project. This happens when I use the Oracle9odp DataProvider. (when using the Oracle9 dataprovider I do not get that error but then I'm not able to insert data to the Many2Many table (no error is shown, data is just not inserted)).... Any further tips would be greatly appreciated.... thanks, again, in advance |
|
|
Hmm, I don't have a nice solution for this, but here is a workaround that worked in my tests: 1. Go into global.asax.cs and add handlers for Application_BeginRequest and Application_EndRequest. 2. In the BeginRequest handler, create a TransactionScope and stash it in HttpContext.Current.Items, e.g. HttpContext.Current.Items["LightSpeedDynamicDataTxn"] = new TransactionScope(). 3. In the EndRequest handler, retrieve this TransactionScope from HttpContext.Current.Items, and Complete it. I have not investigated how this would behave in error cases so you may need to experiment a bit. (I think it would be okay but you would definitely need to test it!) |
|