Not working with ModelMetaDataType Attribute
See original GitHub issueI am using Elect.Web.DataTable to generate datatable response.
I have a ef core generated class like this
public partial class Employee
{
public Employee()
{
EmpSalary = new HashSet<EmpSalary>();
Loan = new HashSet<Loan>();
PfContribution = new HashSet<PfContribution>();
}
public long EmpId { get; set; }
public string EmpFirstName { get; set; }
public string EmpLastName { get; set; }
public string EmpStreet { get; set; }
public string EmpCity { get; set; }
}
And decorated properties of this class like this
[ModelMetadataType(typeof(IEmployeeMetadata))]
public partial class Employee :IEmployeeMetadata
{
[DataTable(DisplayName = "Name")]
public string FullName { get { return this.EmpFirstName + " " + this.EmpLastName; } }
}
public interface IEmployeeMetadata
{
[DataTable(IsVisible = false)]
long EmpId { get; set; }
[DataTable(DisplayName = " First Name")]
[DisplayName("First Name")]
string EmpFirstName { get; set; }
}
DisplayName attribute on property “EmpFirstName” works good on view page with @Html.EditorFor
, but DataTable attributes are not working.
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
ASP.NET Core MetaDataType Attribute not working
The only work-around I've found to work (for me) is to create a new class that wraps the model you're wanting to annotate....
Read more >Microsoft.AspNetCore.Mvc.ModelMetadataType doesn't work ...
TryValidateObject(), but there is no validation metadata. If I add the validation attributes directly to the generated entity, it works. But, of ...
Read more >MetadataType not working to merge metadata having followed ...
MetadataType not working to merge metadata having followed Microsoft tutorial for data first approach. I have tried to simplify this problem ...
Read more >C# – ASP.NET Core MetaDataType Attribute not working
NET Core MetaDataType Attribute not working. asp.net-corec++data-annotations. I'm using the MetaDataType Attribute on my domain model class.
Read more >ASP.NET Core MetaDataType Attribute not working-.net-core
Although this works for a class with annotations, it doesn't work (for me) for partial classes using either [MetadataType] or [ModelMetadataType] attributes ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looks good now.
Thanks for the help 👍
Hi @gauravsingh8026 , I fixed the issue in ver https://www.nuget.org/packages/Elect.Web.DataTable/3.0.5.2
My mistake on checking the Attribute.