I get the following error message when I attempt to add Sieve 2.1.5 attributes (Can Filter, Can Sort) to each of my Model classes.
Error message, "Attribute of this type cannot be used for class in code". Essentially what I would like to do is add the attribute declaration [Sieve(CanFilter = true, CanSort = true)] on each member in each model class so they look like this.
/// <summary>
/// 0=string, 1=drop down from values defined in attr_set table, 2=integer, 3=currency, 4=color, 5=datetime,
/// 6=floating point number, 7=percent, 8=checkbox, 9=non-editable, 10=time of day
/// </summary>
[Sieve(CanFilter = true, CanSort = true)]
public virtual int DataType
{
get;
set;
}
Sieve - Attribute of this Type cannot be used for class in code
Re: Sieve - Attribute of this Type cannot be used for class in code
Is there a way to programmatically add the Sieve attribute to each property in the generated class by programmatically modifying the EF template?
Re: Sieve - Attribute of this Type cannot be used for class in code
So I was able to add the Sieve attribute to a property of the class using the Properties pane. How would I edit the EF template to programmatically add the following attribute to each class property.
<p1:Attributes>
<p1:Attribute Name="Sieve.Attributes.SieveAttribute" Assembly="Sieve, Version=2.1.5.0, Culture=neutral,
PublicKeyToken=null">
<p1:AttributeConstructor />
<p1:Properties>
<p1:PropertyValue Name="CanSort" Type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<boolean>true</boolean>
</p1:PropertyValue>
<p1:PropertyValue Name="CanFilter" Type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<boolean>true</boolean>
</p1:PropertyValue>
</p1:Properties>
</p1:Attribute>
</p1:Attributes>
<p1:Attributes>
<p1:Attribute Name="Sieve.Attributes.SieveAttribute" Assembly="Sieve, Version=2.1.5.0, Culture=neutral,
PublicKeyToken=null">
<p1:AttributeConstructor />
<p1:Properties>
<p1:PropertyValue Name="CanSort" Type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<boolean>true</boolean>
</p1:PropertyValue>
<p1:PropertyValue Name="CanFilter" Type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089">
<boolean>true</boolean>
</p1:PropertyValue>
</p1:Properties>
</p1:Attribute>
</p1:Attributes>
Re: Sieve - Attribute of this Type cannot be used for class in code
JIC
How to add a custom attribute:
a) navigate to Model > Settings > Attributes > select the assembly with the needed attributes and make sure that the needed attributes are checked in the window below, press OK
b) select the needed attribute in the Attributes collection of a particular class property
2. Our documentation doesn't include reference for classes used in the templates, but there are some tips:
* http://www.devart.com/entitydeveloper/e ... eloper.chm (do Properties > Unblock if content is not displayed) > Template System Concepts
* use IntelliSense feature in our T4 Editor (completion list appears when you type the '.' character)
* you can switch to the model in design time to read a description of a particular property in the Properties window
* general T4 reference: http://msdn.microsoft.com/en-us/library/bb126478.aspx
* decompiling C:\Program Files (x86)\Common Files\Devart\EntityDeveloper\EntityDeveloper.Common.dll and C:\Program Files (x86)\Common Files\Devart\EntityDeveloper\EntityDeveloper.Orm.Common.dll may help you to get acquainted with the needed classes and their functionality
If this information doesn't help, specify:
a) the name of the template you are using (e.g.: "DbContext")
b) the issue you have encountered when editing template