Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc C#和Vue.js中的模型和数据注释_Asp.net Mvc_Vue.js_Model View Controller_Data Annotations_Custom Attributes - Fatal编程技术网

Asp.net mvc C#和Vue.js中的模型和数据注释

Asp.net mvc C#和Vue.js中的模型和数据注释,asp.net-mvc,vue.js,model-view-controller,data-annotations,custom-attributes,Asp.net Mvc,Vue.js,Model View Controller,Data Annotations,Custom Attributes,假设我有一个业务对象:(C#) 然后我有一个模型控制器:(C#) 我的问题是;如何从Vue组件访问注释“必需”和“MyCustomAttribute”以及其他注释。我应该在控制器中添加一个方法来获取这些属性吗 [HttpPut("attributes")] public ActionResult<Attribute[]> Attributes(string propertyName) { return getAttributesOf(prope

假设我有一个业务对象:(C#)

然后我有一个模型控制器:(C#)

我的问题是;如何从Vue组件访问注释“必需”和“MyCustomAttribute”以及其他注释。我应该在控制器中添加一个方法来获取这些属性吗

  [HttpPut("attributes")] 
  public ActionResult<Attribute[]> Attributes(string propertyName) { 
    return getAttributesOf(propertyName); 
    // getAttributesOf("str") would return Attribute[]{ RequiredAttribute, MyCustomAttribute(...)} 
  } 
[HttpPut(“属性”)]
公共操作结果属性(字符串属性名称){
返回getAttributesOf(propertyName);
//getAttributesOf(“str”)将返回属性[]{RequiredAttribute,MyCustomAttribute(…)}
} 
有更好的办法吗

[Route("api/[controller]")] 
[ApiController] 
public class ModelAController : Controller 
{
  // ... some contructors and readonly database ...

  [HttpPut("read")] 
  public ActionResult<ModelA> Read() {
    return db.Read<ModelA>();
  }
} 
  import ...

  export default {
    data () { 
      return { 
      annotations: '',
      model: '',
    }; 
  }, 
  
  created: function() 
  { 
    this.values = Read('ModelA'); // reads data in json format returned by ModelAController.Read()
    this.annotation = // ?????
  }, 
}; 
  [HttpPut("attributes")] 
  public ActionResult<Attribute[]> Attributes(string propertyName) { 
    return getAttributesOf(propertyName); 
    // getAttributesOf("str") would return Attribute[]{ RequiredAttribute, MyCustomAttribute(...)} 
  }