Questions tagged [modelmetadata]
The modelmetadata tag has no summary.
88 questions
2
votes
1
answer
1k
views
What is the best way to read metadata from onnx model from C++?
I have model in onnx format that contains attribute "list_classes". I run it with opencv dnn. I need to read this list using C++.
I tried opencv dnn library, but it seems like there is no ...
0
votes
3
answers
662
views
MetadataType not working to merge metadata having followed Microsoft tutorial for data first approach
I have tried to simplify this problem as much as possible and cannot find a solution or fix.
I have followed the second approach ("Add metadata class") in this Microsoft tutorial https://...
2
votes
0
answers
190
views
How to render a menu with Razor using an Editor-Template?
I have an asp.net core 3.1 based app. I like to utilize Display-Templates and Editor-Templates to create the editor views. I am trying to figure out the best approach on how to create editor templates ...
0
votes
1
answer
1k
views
How can I get the EF Core model configuration entity property comment set in HasComment as the html title attribute
Trying to set the title attribute of an html element as the parameter passed to the entity.Property().HasComment(comment) method.
I've tried with no luck:
...
5
votes
0
answers
291
views
Is there a way to effectively make [ModelMetadataType] work across multiple assemblies?
I have an ASP.NET Core 3.1 web API application that has various models used for by its endpoints for input and output of data. Because other C# applications will be communicating with this one, I ...
0
votes
2
answers
2k
views
Accessing custom attributes from model metadata in a tag helper
I am working on a new project in .net Core having previously been working with .net Framework.
I wish to produce html select elements for boolean properties but using custom values instead of True ...
1
vote
1
answer
282
views
Modify DataType attribute dynamically in ASP.NET MVC
I have a ViewModel containing this property:
...
0
votes
1
answer
664
views
AssociatedMetadataProvider in ASP.NET Core
Where I can find AssociatedMetadataProvider in .Net Core?
Or is there a way to implement GetTypeDescriptor in DefaultModelMetadataProvider?
In MVC 5 the DataAnnotationsModelMetadataProvider inherits ...
0
votes
1
answer
273
views
Spring Batch metadata database transaction problem
I am using Spring Batch (version 4.1.2). The problem is the following:
1/ batch job is step oriented (2 steps), the first step loads data from oracle database (customer orders - the only small amount ...
0
votes
0
answers
113
views
Using what expression I can get ModelMetadata info for a single item from a collection?
I have an application that is written using C# on the top of Asp.Net MVC 5.
I have the following model
...
3
votes
1
answer
3k
views
How can I get the metadata of the items in a collection in razor view-engine?
I have a project written in C# on the top on ASP.NET MVC 5 framework. I am trying to decouple my views from my view model so I can make my views reusable. With the ...
2
votes
0
answers
351
views
Tests involving TryValidateModel fail when run with test using custom HtmlHelper
I have a test of an HtmlHelper extension method that works great when it is the only test that I run. It appears below. All of my other unit tests succeed when I run them, as long as I don't run ...
0
votes
0
answers
275
views
Entity Framework Core metadata is different than model and DB. How to refresh?
I'm new to using EF but it was relatively simple to implement for me, the problem came when I need to change the model. I created a column that I later deleted. However, at runtime the ghost column is ...
0
votes
1
answer
2k
views
How can I disable required attribute on a property in a model in web api?
How to disable the [Required] attribute that has been set on a model property.
I tried with below code using new keyword but ...
6
votes
2
answers
10k
views
Get ModelMetadata for a class in .NET Core
In Entity Framework 6 I could get the ModelMetadata for a class (myModel) like this:
...
3
votes
1
answer
1k
views
How should I store metadata in an object?
In my Java application, I store some data in serveral files in a proprietary format. At runtime, the content and some metadata are stored in an object. In my current approach, the class looks like ...
0
votes
1
answer
203
views
Extending CachedDataAnnotationsModelMetadataProvider to not cache some DataAnnotations
I'm trying to extend CachedDataAnnotationsModelMetadataProvider to not cache Custom ValidationAttribute.
How can i achieve this? ...
4
votes
1
answer
7k
views
Get the column name from the database in entity framework 6 database first with different property name in mapping
I am into a situation that my table names are different from the class property on the model using mapping in EF 6. the Model and Database goes like this:
...
2
votes
1
answer
1k
views
ModelMetadata.Container property is null
I am writing a custom ModelMetadataProvider which extends default DataAnnotationsModelMetadataProvider. Unfortunately i came ...
0
votes
1
answer
356
views
Localized ModelMetadata and Caching
I'm having problems with my localized Model attributes as we decided to not use the build-in localization functionallity.
...
-1
votes
2
answers
1k
views
ModelMetadata additional attributes is always empty
I am trying to access a model's metadata attributes to create a helper to automatically add HtmlAttributes based on DataAnnotations.
Problem is, the attributes are always empty.
I have 2 basic ...
5
votes
1
answer
3k
views
Get Types using IEnumerable GetGenericArguments
I have developed a MVC helper for generating display and editable tables (a jquery plugin is required to allow dynamic addition and deletion of rows with full postback in the editable tables) e.g.
<...
4
votes
1
answer
8k
views
Add new Property to MVC ModelMetadata
I'm seeing alternative approaches to this such as AdditionalValues, but I'm wondering if it's possible to end up in a scenario where you can add a new property to the ModelMetadata object available in ...
1
vote
0
answers
118
views
Get AdditionalValues from containerType's instance
I have something like that:
[ViewTerms]
public class Foo
{
[Term]
public string Name { get; set; }
}
my ViewTermAttribute sets some additional values ...
5
votes
1
answer
2k
views
How to Transfer DataAnnotation metadata to ViewModel with AutoMapper with Betty's Approach
I need clarification on how to implement Betty's code solution to transferring data annotation metadata to ViewModels with AutoMapper (see here). Or if you have a better way, please share that. Maybe ...
2
votes
2
answers
3k
views
Getting the attributes of the field in additional EditorTemplate
I want to make additional editor template for the Int32. In it I want to get all attributes(custom/default-data-annotations) and do some work with them:
...
1
vote
1
answer
311
views
Equivalent for "ModelMetadata.IsComplexType" using Reflection
I'm trying to use System.Reflection to get the same result for a property as with using the metadata, specifically the ...
4
votes
1
answer
1k
views
How can I extend CachedDataAnnotationsModelMetadataProvider?
We are looking to use CachedDataAnnotationsModelMetadataProvider as it improves performance and we use a lot of Meta Data in our MVC4 application.
We are currently ...
0
votes
1
answer
664
views
.NET Custom Strongly Typed HTML Helper with deep property navigation
I've searched all around, read all the posts related to creating a strongly typed helper, but none have addressed my issue. Problem:
When referencing a simple property, all works well:
...
0
votes
0
answers
140
views
Modelmetadata is populated for outer model, but not inner model,
I need reading material on how modelmetadata is populated and when the OnMetadataCreated method is called in the framework. When I created a viewmodel that contains a nested viewmodel, ...
3
votes
1
answer
2k
views
ModelMetadata TemplateHint always null
I am trying to create a custom ModelMetadataProvider to provide unobtrusive attributes for the JQuery UI Autocomplete widget.
I have a custom attribute that looks ...
3
votes
1
answer
3k
views
ASP.NET MVC - Model's metadata used from model object type instead of declared model of the View
I have interface of a model declared, with class implementing it:
...
4
votes
1
answer
3k
views
How do I get the fully qualified member name in an EditorTemplate?
I have an ASP.NET MVC 4 site and I am passing a nested property to an EditorTemplate and building the field name using ViewData.ModelMetadata.PropertyName however, ...
0
votes
0
answers
93
views
How can I break up Lambda expression into the objects that make up the expression?
Given an expression such as:
m => m.Employee.Address.Line1
I need to create a function that can walk the expression, pulling out the objects involved, or AT LEAST the final object in the chain (i.e. ...
7
votes
2
answers
2k
views
Can I use an IMetadataAware attribute multiple times on the same field?
I have fields that different people should see in different names.
For example, suppose I have the following user types:
...
2
votes
0
answers
482
views
Modifying model property metadata in HtmlHelper
I am trying to create a custom HtmlHelper that displays a numeric value formatted to a given number of decimal places. My idea is to change the ModelMetadata.DataFormatString property to achieve this. ...
0
votes
0
answers
51
views
MVC 3, ModelMetadata weird behavior during navigation
One of the properties in my model is decorated with Hide attribute. When I load a page this property is not displayed (as expected). When I click "Back" and then "...
0
votes
2
answers
10k
views
How to override Entity Framework validation error messages
I have an Entity Framework 4.1 model that supports multiple ASP.NET MVC web applications. I use DataAnnotations to define and localize label text and validation rules and error messages.
For some ...
2
votes
1
answer
4k
views
MVC Html Helper: modelmetadata from string expression
I am trying to build an html helper that would have access to modelmetadata.
I need both versions of helper to work: from string expression and from lambda expression:
Example:
...
1
vote
2
answers
3k
views
How to add MetaData to a dynamically build MVC3 ViewModel?
One of the key features of a project I'm working on is the ability for the user to configure Forms (as in "Forms" to fill-up) based on a pool of pre-existing field types (well known types, for ...
0
votes
2
answers
535
views
Validation Application Block - How to use validation metada class
I'm using VAB to validate some classes with attributes and I'm using a metadata class to share the same validation among different classes.
When i try to validate an object in the controller (btw i'm ...
1
vote
1
answer
1k
views
How do I Get Full Html Field Name for an item in a list on my model at controller level?
*First Post
I have a JQuery error handler for my Ajax posts that I must use, it appends an error to the html based on the field name for that element like this
...
0
votes
1
answer
233
views
Apply model metadata on complex objects
I have the following scenario
...
2
votes
1
answer
2k
views
Do model metadata providers in ASP.NET MVC 3 support dynamic metadata?
I'm trying to implement some custom model metadata in ASP.NET MVC 3. I can't use data annotation attributes since some of the metadata could change based on configured values, so I need a solution ...
11
votes
2
answers
3k
views
Custom Html helper that can browse DataAnnotations
Say I have a model like this
...
16
votes
3
answers
6k
views
Technique for carrying metadata to View Models with AutoMapper
I use AutoMapper to map my domain objects to my view models. I have metadata in my domain layer, that I would like to carry over to the view layer and into ModelMetadata. (This metadata is not UI ...
0
votes
2
answers
538
views
In MVC 3.0 when Setting IsRequired to the ModelMetadata of a Property, it doesn't add the validation
There are certain properties in my application that I need to set dynamically whether they are required or not, therefore I can not use the [Required] atribute of Data Annotations.
Maybe this is not ...
27
votes
5
answers
31k
views
Is it possible to override the required attribute on a property in a model?
I'm curious to find out if it is possible to override the [Required] attribute that has been set on a model. I'm sure there most be a simple solution to this problem, any takers?
0
votes
2
answers
2k
views
WCF model class from metadata not updating
I have a WCF service that uses a separate project for a DAL, which I have a reference to, and can access the entity objects with the DAL, through the service as such:
...
1
vote
1
answer
427
views
ability to change the ModelMetadataProviders.Current in areas
I have a special case where I would need the ability to use multiple ModelMetadaProviders in an application. Certain area would use a specific provider, another area will use some other. I mainly need ...