- Home
- LLBLGen Pro
- Bugs & Issues
Browsable(false) should also have ScaffoldColumn(false)
In the generated files (Entity) and probably others TypedList / TypedView. There are many methods decorated with [Browsable(false)] like:
public bool AlwaysFetchGroupAuditInfos and public bool AlreadyFetchedGroupAuditInfos
I am proposing that any one decorated with Browsable and probably others should also have [ScaffoldColumn(false)] because if you auto create the view it will add these as fileds or columns. Also if you use the dynamic methods these will show and you can't decorate them in a separate class, the 3rd place I've had this happen is with the Telerik grid where if you don't specify the columns it inspects the object and finds them all.
Now I could manually go through every generated class and do this, but I would really really appreciate if it could be done auto-magically for me. Is there a change I can do to the templates (for now) that will do this? And could 3.1 have this feature ?
Here are a some others:
Always Fetch User
Already Fetched User
User Returns New If Not Found
Always Fetch User_
Already Fetched User_
User_ Returns New If Not Found
Is New
Is Dirty
So that is some of them, there may be others.
quentinjs wrote:
In the generated files (Entity) and probably others TypedList / TypedView. There are many methods decorated with [Browsable(false)] like:
public bool AlwaysFetchGroupAuditInfos and public bool AlreadyFetchedGroupAuditInfos
I am proposing that any one decorated with Browsable and probably others should also have [ScaffoldColumn(false)] because if you auto create the view it will add these as fileds or columns.
'ScaffoldColumnAttribute', which framework defines that? WPF?
Also if you use the dynamic methods these will show and you can't decorate them in a separate class, the 3rd place I've had this happen is with the Telerik grid where if you don't specify the columns it inspects the object and finds them all.
We implement ITypedList, which filters these properties out. What they likely do is simply reflect over the object they create with AddNew() and add every property they find.
I don't know which UI framework we're talking about, so I don't know if there's a binding source thing which can help you with this. Winforms' BindingSource could help as it obeys ITypedList.
If Telerik would obey the standards, it also would have solved its cyclic references problem, as ITypedList solves that too. I'm sorry to point at a 3rd party for this. What I find surprising is that they don't obey ITypedList.
What does 'dynamic methods' mean btw?
Now I could manually go through every generated class and do this, but I would really really appreciate if it could be done auto-magically for me. Is there a change I can do to the templates (for now) that will do this? And could 3.1 have this feature ?
Here are a some others:
Always Fetch User Already Fetched User User Returns New If Not Found Always Fetch User_ Already Fetched User_ User_ Returns New If Not Found Is New Is Dirty
So that is some of them, there may be others.
Some are in the runtime framework. We won't add a hard-coded assembly reference to some higher level .NET assembly just for the Scaffolding attribute, because that makes it impossible to run our code on .NET 2.0, plus it's IMHO not useful to add a reference to an assembly which is used in UIs to a runtime framework just because some control vendor doesn't obey standards. If Telerik wants to contact us about this, please let them know that they can do so, we worked with Infragistics as well to make their controls work properly with ITypedList.
I am also not sure what / how you're binding. If you bind through an entity collection or entity view, ITypedList is implemented and should be obeyed by the binding contol.
Hi Otis,
So the **[ScaffoldColumn(false)] **is a DataAnnotation in System.ComponentModel.DataAnnotations. Just Like **[Browsable(false)] **which is in System.ComponentModel. It looks like ScaffoldCollumn was introduced in .net 3.5
The problem is that I can not create a ** [MetadataType(typeof(SomeEntity))]** which I can do anything with those methods that have been marked with Browsable(false). But the Entity class can still be introspected and those methods will still generate fields in my form using the MVC View method <%: Html.EditorForModel()%>
So for me to remove them, I need to manually edit every Entity / TypedList that is generated and add in the **[ScaffoldColumn(false)] ** which will then make them not show. And what is worse is that I need to do this EVERYTIME the classes are generated, which is fairly frequently.
So I am using MVC 2, .NET 4, LLBL Entities.
My reference to dynamic methods was those that were generated in the EntityClass for example. I think we can disregard that thought.
And yes Telerik will also see these, but that is less of a concern then the MVC. Since your already marking them as Browsable(false) adding another decorator for ScaffoldColumn(false) should not impact anyone as it just surpresses those further.
I hope I clarified what I meant. I seem to confuse everyone in every post I do lately which makes me scratch my head as I believe I am being clear in what I am describing, but based on my recent posts (else where on the web as well) it bodes badly for me.
quentinjs wrote:
Hi Otis,
So the **[ScaffoldColumn(false)] **is a DataAnnotation in System.ComponentModel.DataAnnotations. Just Like **[Browsable(false)] **which is in System.ComponentModel. It looks like ScaffoldCollumn was introduced in .net 3.5
This is a problem, because the runtime is build against .net 2.0, and not only that, by decorating properties with that attribute, the ormsupportclasses also get a reference to System.ComponentModel.DataAnnotations, something we won't do.
The problem is that I can not create a ** [MetadataType(typeof(SomeEntity))]** which I can do anything with those methods that have been marked with Browsable(false). But the Entity class can still be introspected and those methods will still generate fields in my form using the MVC View method <%: Html.EditorForModel()%>
So, Html.EditorForModel creates an editor from a class interface, but you can't add a buddy class because the properties are marked as Browsable(false) and buddy classes don't work for those?
So for me to remove them, I need to manually edit every Entity / TypedList that is generated and add in the **[ScaffoldColumn(false)] ** which will then make them not show. And what is worse is that I need to do this EVERYTIME the classes are generated, which is fairly frequently.
Also for typedlists? Because that are typed datatables, which derive from datatable, and have the same problem: DataTable implements IListSource, similar to EntityCollection, which will then tell the control that the real source to bind to is the DataView, which is similar to the entitycollection which will tell you the object to bind to is an EntityView.
But I also don't understand what you're doing exactly. You say you add scaffoldcolumn, but the properties you talk about are in the base class, i.e. in the entitybase(2) classes (for entities) so which properties are you decorating?
And yes Telerik will also see these, but that is less of a concern then the MVC. Since your already marking them as Browsable(false) adding another decorator for ScaffoldColumn(false) should not impact anyone as it just surpresses those further.
It's about references to assemblies not everyone has installed.
I hope I clarified what I meant. I seem to confuse everyone in every post I do lately which makes me scratch my head as I believe I am being clear in what I am describing, but based on my recent posts (else where on the web as well) it bodes badly for me.
No worries. What you should think about is posting more example code. E.g. you mention above you decorate properties with ScaffoldColumn, but don't mention which one, or how. Also you mention you do it for typedlists, but don't mention which properties. You don't have to post buckets of code, just 1 or 2 properties is enough. This will enlight what you want to do. If you're decorating properties which are in the base class, you can do so in a partial class of CommonEntityBase. This will preserve your code.
I can create a buddy class, and I can decorate those properties I created. Just not all of them. This list was a list of some of the generated methods that had the Browsable(false) added to them.
[quote] Always Fetch User Already Fetched User User Returns New If Not Found Always Fetch User_ Already Fetched User_ User_ Returns New If Not Found /quote]
Personally now that LLBL 3.0 does MetaData I'd like to do as much as I can in the designer if possible.
Question(s) 1. .net 2 has been out for quite some time, is there plans to start using .net 4?
-
Could we use compiler directives so if you are compiling in something after 3.5 then allow them? I get a real feeling of .net 2.0 is very important line in the sand and you don't want to cross it.
-
Can we extend the Designer? Right now I can do Project -> Properties -> Code Gen meta defaults. A. And under there is Entities which allows decorating of the entity classes (I'm not currently using).
B. And I can decorate Normal Fields C. But how about another option for the other fields? This would remove the problem of scaffoldcolumn() from your hands all together ? D. You already generate for different .net versions, I made the assumption that the DAL would also be using functionality from that version (eg .net 3.5). Something could be added to say use functionality from these versions in the DAL as well. Then the developer is aware.
To confirm, my typedlists also have methods like:
[Browsable(false)][ScaffoldColumn(false)]
public virtual Hashtable CustomPropertiesOfType
Others being from EntityClasses decorated include:
public bool AlwaysFetchProjectAuditInfos
public bool AlreadyFetchedProjectAuditInfos
public virtual UserEntity CreatedByUser
public bool AlwaysFetchCreatedByUser
public bool CreatedByUserReturnsNewIfNotFound
public virtual UserEntity ModifiedByU
There are 2 that I need decorate in my buddy Class and I can't find in the generated code so I can hide them.
isNew
isDirty
I found it easier to just do them all as it doesn't hurt me, and its faster then running my app, and for each entity / typedlist getting a list and then searching for each one in the code. Generattors are supposed to make your life easier so you can get more done in less time
And yes Telerik will also see these, but that is less of a concern then the MVC. Since your already marking them as Browsable(false) adding another decorator for ScaffoldColumn(false) should not impact anyone as it just surpresses those further.
It's about references to assemblies not everyone has installed.
I think either the compiler directive option or option "D" above that I just added would be afe for this, it allows the dveloper to be aware of the additional assemblies.
A little off topic, but I know that in many generated classes many of the uses references are not being used. I have an add on to VS2010 that shows me the unsued ones, or I'd have never known. If there is a performance loss from these or code bloat then you might want to review these as well, if that is a concern. The add-on is by http://www.axtools.com/ and can be added from Tools->Extension Manager. I have to say I didn't expect much from it, but its well worth installing. A very brief overview is here -> http://visualstudiogallery.msdn.microsoft.com/en-us/1c54d1bd-d898-4705-903f-fa4a319b50f2?SRC=VSIDE
[quotenick="quentinjs"]I can create a buddy class, and I can decorate those properties I created. Just not all of them. This list was a list of some of the generated methods that had the Browsable(false) added to them.
Always Fetch User Already Fetched User User Returns New If Not Found Always Fetch User_ Already Fetched User_ User_ Returns New If Not Found
/quote]
Personally now that LLBL 3.0 does MetaData I'd like to do as much as I can in the designer if possible.
True, but it can only append the attributes to elements which are in the model, the fields you refer to are in the base classes.
You can solve this with a custom template btw: generate buddy classes which append the scaffold attribute to the fields of the generated entity classes. This way, you don't have to hand-write them nor do your changes get lost when you re-generate .
Question(s) 1. .net 2 has been out for quite some time, is there plans to start using .net 4?
- Could we use compiler directives so if you are compiling in something after 3.5 then allow them? I get a real feeling of .net 2.0 is very important line in the sand and you don't want to cross it.
It's about maintainability: 1) adding a reference to a UI oriented assembly means the ORMSupportClasses as well as the generated code classes have to be forked for the specific platform the assembly is used on. This means we have to make two code bases: one for .NET 2 (which doesn't have the assembly reference) and one for .NET 3.5 and higher. As this is a tremendous burden, we won't do it. 2) adding a reference to the UI oriented assembly also means that the ormsupportclasses can't be split up into smaller assemblies to apply to the .NET 4 client profile. At the moment they don't apply to that because the web stuff is in there too, but for v3.1 we will split the assembly up into smaller assemblies so the ormsupportclasses dll is compatible with the .NET 4 client profile
- Can we extend the Designer? Right now I can do Project -> Properties -> Code Gen meta defaults. A. And under there is Entities which allows decorating of the entity classes (I'm not currently using).
B. And I can decorate Normal Fields C. But how about another option for the other fields? This would remove the problem of scaffoldcolumn() from your hands all together ?
You can extend the designer (plugins, which can for example bind to designer events), but that won't help, as some properties are in the base classes.
D. You already generate for different .net versions, I made the assumption that the DAL would also be using functionality from that version (eg .net 3.5). Something could be added to say use functionality from these versions in the DAL as well. Then the developer is aware.
The code can be generated for multiple .net versions, but the source is always the same. The amount of template code is big and in previous versions we had .NET 1.x and .NET 2.x, with each an individual code base and maintainability was a serious problem (serious as in: a decision has to be made to cut one off to be able to maintain the other). We wont go back there.
... There are 2 that I need decorate in my buddy Class and I can't find in the generated code so I can hide them.
isNew isDirty
Can't you hide them in a buddy class? If so, please generate those. It's easy to do with a simple template. If you need help with that, please let us know.
And yes Telerik will also see these, but that is less of a concern then the MVC. Since your already marking them as Browsable(false) adding another decorator for ScaffoldColumn(false) should not impact anyone as it just surpresses those further.
It's about references to assemblies not everyone has installed.
I think either the compiler directive option or option "D" above that I just added would be afe for this, it allows the dveloper to be aware of the additional assemblies.
A compiler directive would still require to create a lot of work for this, which is something we simply can't do, it's too maintenance intensive. As things can be decorated outside the codebase, that's the more usable option. The thing then is: how to decorate them without doing a lot of work. A custom template which is added to the preset you use is IMHO the easiest way to do this, as you can then simply generate the buddy classes for the entities you want (you can drive this with a custom setting you added for example, see the SDK docs, so you can for example add a setting for 'entity' and set it to true for the entities you want to have buddy classes to be generated for, and in the preset set the rule to run the template if the setting is true. Again, if you need help with this, just let us know)
A little off topic, but I know that in many generated classes many of the uses references are not being used. I have an add on to VS2010 that shows me the unsued ones, or I'd have never known. If there is a performance loss from these or code bloat then you might want to review these as well, if that is a concern. The add-on is by http://www.axtools.com/ and can be added from Tools->Extension Manager. I have to say I didn't expect much from it, but its well worth installing. A very brief overview is here -> http://visualstudiogallery.msdn.microsoft.com/en-us/1c54d1bd-d898-4705-903f-fa4a319b50f2?SRC=VSIDE
namespace using statements aren't a problem. Project level assembly references are all necessary to make the code compile. Code is loaded into memory once anyway, each object instance refers to the same IL, so 'code' is really cheap.
Hi,
I cooked something for you. In the attached zip you will find some templates that generate buddy classes for all entities. Also they will disable Scaffold for those attributes you don't want to see when using Html.EditorForModel().
Additionally they will disable Scaffold for relations, as I saw Html.EditorForModel() also generate html code for them.
To install and use them follow these easy steps: 1. Unzip all the contents into LLBLGen v3.0 installation folder. Merge the folders. 2. Open your LLBLGen project and hit F7 (generation dialog) 3. At "Task queue to execute", add CT.Tasks.Adapter.MetaDataAnnotations.Scaffold task. At this point you can save a new preset file if you want. 4. Click "Generate Code"
The templates work with Adapter, C# and .NET 3.5/4.0. However they are usable in SelfServicing I think. The task generates just one file, in that file you will find all metadata info for entities. The file is generated in your DBGeneric folder.
(Edit) I just realized that your problem is with TypedView/TypedList and the templates posted are for Entities. Wont be difficult to you to make it work with other objects.
Tip: look into the template posted and look also the constantsEnums.template file at LLBLGen Pro v3.0\Frameworks\LLBLGen Pro\Templates\SharedTemplates\Net2.x\C#. So you just need to add some code to make it work. If you want more info about working with templates please read SDK manual.
Good luck.
Filename | File size | Added on | Approval |
---|---|---|---|
MetaDataAnnotationTemplates_20100918.zip | 3,499 | 20-Sep-2010 04:29.12 | Approved |
I tweaked the files for Self-Service. When looking at the file, I see the following:
[ScaffoldColumn(false)]
public EntityCollection<GroupAuditInfoEntity> GroupAuditInfos;
What is EntityCollection, as it seems to be a problem
Slowly getting there on thhe 2 new templates... found a typo in your error message...
Could not find template 'CT_MetadataScaffoldEntity'. It is not defined in the used templatebindings or is empty. It can be it's not defined for the current database (e.g. stored procedure templates for SqlServer CE)
Replace "defined in the used templatebindings" an option is: "defined in the defined templatebindings"
Replace "It can be it's not" a couple options are: "It can be that it's not..." "It is likely that it's not..."
Good news & Bad News....
The Good News is I have all the buddy classes creating for Entity, TypedView and TypedList.... with the the DA's required for each type.
... the bad news is you can only have ONE buddy class per class, so the problem is either I need to copy my DA's into these generated buddy classes (not a good plan) or some how I need to have these scaffold DA's incorporated directly in the actual classes... which I think is the preferred approach.
I'm starting to think I am talking to myself!
quentinjs wrote:
Sorry, just the last point trlated to the Bad News, as I am stuck on that. I can only have 1 buddy class.
Oh, I see. I'm not an expert in buddy classes, it looks like a problem that you can only have one of these. Can you use "partial" in buddy classes so you can define some other DA's in some other files?
quentinjs wrote:
There is a FYI before on an error message, but thats for you to look at.
I'm lost in that FYI, I don't know what are you talking about
quentinjs wrote:
Slowly getting there on thhe 2 new templates... found a typo in your error message...
Could not find template 'CT_MetadataScaffoldEntity'. It is not defined in the used templatebindings or is empty. It can be it's not defined for the current database (e.g. stored procedure templates for SqlServer CE)
Replace "defined in the used templatebindings" an option is: "defined in the defined templatebindings"
No, it has to be 'used' as more templatebindings can be defined but not all of them are used due to scope restrictions (e.g. the selections you make when generating code)
Replace "It can be it's not" a couple options are: "It can be that it's not..." "It is likely that it's not..."
Will rephrase that.
Can you use "partial" in buddy classes so you can define some other DA's in some other files?
Unfortunately not....
[MetadataType(typeof(ProjectViewTypedListMd))]
public partial class ProjectViewTypeList
{
}
Its the [MetadataType()] that its blowing up on when it finds that it has been declared twice for the same class, for example ProjectViewTypeList.