MetaChildrenColumn.ReadOnly

Posts   
 
    
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 25-Nov-2009 17:07:11   

In DynamicData I would like to make columns which represents OneToManyRelations editable. MetaModel has MetaChildrenColumns for this.

let's say: I have relation: Customer 1:n Order. MetaChildrenColumn Order should be editable in MetaTable Customer.

LLBLGenProDataModelProvider adds to any MetaChildrenColumn ReadOnlyAttribute=false

I tried to add ReadOnlyAttribute=false to the the property of type EntityCollectionBase<SomeEntity> with the same name as related MetaChildrenColumn's Name like following:

foreach (IEntityRelation relation in ((EntityBase)entity).GetAllRelations())
{
  if (relation.TypeOfRelation == RelationType.OneToMany)
  {
    PropertyInfo info = entity.GetType().GetProperty(relation.MappedFieldName);
    InMemoryMetadataManager.AddColumnAttributes(info, new ReadOnlyAttribute(false));
  }
}

as well as I tried to override the property in LLBL project with attribute [ReadOnly(false)]

but none of those work's! cry

Is there any way, how to

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 26-Nov-2009 12:05:39   

what exactly doesn't work? If you have a customer, you can see its orders, you can then edit one of them in THAT grid, or am I missing something? At which screen does this editing occur?

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 27-Nov-2009 13:08:53   

OK, maybe customer and orders isn't good example.

Let's say I Have User - UserRole - Role tables., cardinality between User and Roles is m:n

I want to select roles when editing User record.

If you look at the FieldTemplates, there's Children.ascx fieldtemplate. In list of Users is column UserRole which contains hyperlink "View UserRoles" (from children.ascx field template).

If I click Edit User, there're all fields editable except UserRoles. There's still the hyperlink

I made Children_Edit.ascx, which contains CheckBoxList. In this case it would shows Roles records as ListItems.

Problem is, that Children_Edit.ascx is never used, because all MetaChildrenColumns (in this case MetaColumn UserRoles in MetaTable Users) has ReadOnlyAttribute.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 27-Nov-2009 13:58:07   

I have no idea why this happens, because it's not marked as ReadOnly in the meta-data code (See LLBLGenProEntityProvider.cs, line 219)

Could be dyn. data makes it readonly but I don't know why. All m:1 related entities are readonly in the dyn. data generated app?

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 27-Nov-2009 20:49:21   

Is the meta-data code (LBLGenProEntityProvider) available for download?

I'm using only Dynamic Data base with LLBL and there's are all ChildrenColumns ReadOnly, not sure about DD with LingToSql, but I've found tutorial for MultipleSelect_Edit field template what needs ChildrenColumn

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 28-Nov-2009 10:49:34   

you are using our DD addon? http://www.llblgen.com/pages/downloads.aspx

I see the sourcecode isn't in that package. Anyway, do you see the same behavior in other 1:n relationships?

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 30-Nov-2009 15:40:05   

yes, it seems to be the same for all 1:n relationships.

I tried to create the Microsoft's default Dynamic Data Project with LinqToSql classes and it works fine!

I think the problem is somewhere in MetaDataProvider.

maybe it's becase the property in llbl generated code has no setter? e.g. public virtual LLBL.CollectionClasses.UserRoleCollection UserRole in UserEntityBase.cs

EDIT: If I add [ReadOnly(false)] to LLBL code attribute value IsReadOnly is overwritten to true.

If I add ReadOnlyAttribute using InMemoryMetadataManager at runtime when registering context I can see it later in AttributeCollection while debuging and the attribute has the right value (false), but the Columns Property IsReadOnly is still true.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 30-Nov-2009 17:10:06   

You DO use our DD extension? You didn't answer that question.

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 30-Nov-2009 17:18:07   

When using original DD column is not readonly, when using your it is.

I think I've got the reason.

MetaColumn.IsReadOnly returns Column.Provider.IsReadOnly and it returns LLBLGenProEntityFieldProvider._isReadOnly. When I changed it to true using debug manager(quick watch simple_smile ) it finally worked.

So it has nothing to do with MetaData Attributes

{
public virtual bool get_IsReadOnly()
{
    if (!this._isReadOnly.HasValue)
    {
        PropertyDescriptor propertyDescriptor = this.PropertyDescriptor;
        this._isReadOnly = new bool?((propertyDescriptor != null) ? propertyDescriptor.IsReadOnly : false);
    }
    return this._isReadOnly.Value;
}
}

But this is not solution.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 30-Nov-2009 17:31:55   

Well, I don't know what you kind of special things you're doing, but here it works OK. confused

I created northwind adapter code, added Dynamic data project (for adapter) using our provided vs.net project template, modified the global.asax.cs file as indicated and when I click 'Order' at the start page I can click 'Edit' on an order and then I can select Customer, Employee, etc. and save it properly, updating the order.

You're talking about the COLLECTION side, but you have to look at the ENTITY side, so in the case of Customer - Order, you've to look at the Order side, which has a property Customer which is writable.

So for you to test: (I do assume you use the latest builds of runtime lib, templates, dyn. data extension) - create project on northwind, generate code - create new solution, add projects to it - Add dynamic data project using OUR template vs.net project, not the normal one. - modify global.asax.cs as indicated, start app, click Order and you should be able to modify customer and employee using combo boxes.

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 30-Nov-2009 23:51:16   

You are talking about MetaForeignColumn. In order edit view you can edit Customer using DropDownList (by default). In details view it is displayed as link to Customers details. (ForeignKey.ascx) this is ok, but I want is to edit orders in Customer edit page.

On the customer side is MetaChildrenColumn Order. In customers details page is link to list of orders filtered by customer. This is Children.ascx. There's no Children_Edit.aspx template by default but we can create one. I did so in Dynamic Data project which is not using LLBL.

Since MetaChildrenColumn is always readonly when using llbl dd addon, Children_Edit.aspx will be never generated.

Maybe it sounds absurd, but edit children column is very practical and userfriendly in many cases.

For example: Using CheckBoxList for assigning Roles to users, or assiggning more then one group for product etc.

I have made simple changes into SD.LLBLGen.Pro.DynamicDataSupportClasses.NET35.dll using .NET Reflector and it is working somehow so I can close the thread. But it wouldn't be problem for u to fix it for others

this is something similar to what i'm trying for: http://www.codeproject.com/KB/webforms/DynamicDataManyToManyFld.aspx

_* we are using SelfServicing template_

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 01-Dec-2009 10:47:11   

I still don't follow what differences you see compared to what I see.

When I click on CustomerEntity, I see a list of customers, with 'Edit' at the front and also at the end the Order link. When I click on 'Order' at the right of some customer, I go to the list of orders of that customer. I can then click 'edit' to edit one order, or add a new one by clicking the 'Insert new item' link at the bottom.

This does allow you to add new elements to a parent, e.g. new orders to a customer, or edit the order of a customer. They're not readonly here. When you click on the view order link at the right, or when you click the view order link at the bottom when you click 'Edit' for a customer, you should be able to edit the order and add new ones, exactly as you wanted.

I know this requires clicking an extra link, but I don't see what difference there should be made to the meta-data as the meta-data apparently produces the right data? (otherwise the edit forms here wouldn't work as well... )

We just followed the pages provided by MS in their dynamic data offering, and that included no children_edit (as it would be redundant, as there is already a way to do that). You apparently made changes to the IL using reflector (I didn't know it could do that) but I don't know what you changed, as apparently the meta-data is already producing data enough to allow editing the data?

I know it can be easier to edit the Orders on the customer page (similar to our asp.net templates which generates a UI for you), though I don't see why it's not possible to do so, with the current dd offering, as I clearly could add orders to a customer and edit them?

If you've changed code, why not tell us what you changed? You have to realize that everything you DONT tell is will cause us more time to try to look into your problem, and frankly that's starting to annoy me a bit, no offence.

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 01-Dec-2009 21:41:46   

this should explain it. I can't say it more clearly.

http://www.tsmaestro.aspdotnet.sk/ddscreen.png

in LLBLGenProEntityFieldProvider.cs in constructor is line:

this.IsGenerated = isReadOnly; I dont understand it, but what I added to the constructor:

if (relationProvider.Relation.TypeOfRelation == SD.LLBLGen.Pro.ORMSupportClasses.RelationType.OneToMany)
{
   this.IsReadOnly = false;
}

I'm not sure if this worked because i have also code from the screen on another place. rage The method using reflection from screen solved the problem.

EDIT: to test it, make a copy of DynamicData/FieldTemplates/children.aspx, name it children_edit.aspx and made some change into it, so you will see wich template is used. Then do to edit view of customer and check orders column.

if it were readolny, children.aspx would be used, if not readonly, children_edit.aspx.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 09-Dec-2009 11:19:39   

We haven't forgotten about you.

As I understand it: The flag to readonly is set as the property is readonly (the collection), the collection itself isn't. So setting this to false, which makes the property settable, isn't going to work as the collection set into the property isn't going to be saveable. At least I don't see how. Also m:n relationships are readonly as well, and therefore not editable (if they were even supported).

After v3's release we'll look into providing the full sourcecode of these add-on libraries as we want to get rid of the burden to actively support them, which is actually a pretty undoable process: MS releases a lot of these platforms which are easily forgotten and phased out from their side (and changed dramatically) however we ISVs keep on supporting these old frameworks. For example their v1.0 dynamic data which we support is actually so broken, it's not really useful in production. (use it with adventure works and you know why wink )

So we won't drop the ball on dynamic data and other services MS might cook up, we just don't want to ship a binary dll anymore, but instead offer sourcecode so users can grab that sourcecode and get the support if they want to.

Frans Bouma | Lead developer LLBLGen Pro
Liero
User
Posts: 40
Joined: 18-Sep-2009
# Posted on: 22-Dec-2009 10:58:54   

Sorry about reopening the thread but to explain:

I made BaseInsertPage and all the Insert Page templates (original as well as customized) are derived from it. I simply made my own Save method which includes BL validation, applies different rules from BL, etc. The method simply looks at all fields in DetailsView and those which are metachildrencolumn I saved separately using interface method in field template.

We have spend much of time to make DD usable and we have added many new features. Now I consider it very usable product which saves much of time and we have already made some successfull projects using it. Now most of the development time a have to care only about the BL, not writing user interface. I'm quite proud about it simple_smile

I understand the problems with support and changes in DD releases. We have our own experiences as well.

However, I would be really unhappy to hear from you about not supporting the DynamicData in .Net 4.0. It seems to be changed a lot but I hope the future releases will be more compatible with the 4.0 release. This would be probably reason for switching to LinqToSql in some projects and this is really nightmare for me.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 23-Dec-2009 18:59:36   

'Not supporting' is a big term simple_smile . We'll very likely go the sourcecode route. So we provide the sourcecode of the library and if you need it, or need to tweak it, it's there, change it etc. If you have adjustments, mail us, we'll add them and the sourcecode is update.

This means that there's no pre-fab dll shipped, it's sourcecode you've to compile and use. The difference is that we can take a step back and put our time in the core library and designer instead of every framework designed by MS.

So the code won't go away, it's just shipped in sourcecode instead of binary simple_smile

Frans Bouma | Lead developer LLBLGen Pro