您的位置:首页 > 其它

ModelName标记的使用

2017-03-06 14:42 29 查看
再项目中出现这样的错误:

A model description could not be created. Duplicate model name 'ExamInfoParams' was found for types 'A.WebAPI.Params.QualityControl.ExamInfoParams' and 'A.WebAPI.Params.Exam.ExamInfoParams'. Use the [ModelName] attribute to change the model name for at least one of the types so that it has a unique name.

出现这个问题的原因 在于两个文件名相同,虽然命名空间不一样但是还是被程序不能区分,这时候需要使用特殊的标记去区分两个类,例如:

[ModelName("eWorld.WebAPI.Params.QualityControl.s")]
/// <summary>
/// 检XXXX
/// </summary>
public class Params : Bs
{
/// <summary>
/// 检查唯一号
/// </summary>
public Guid UID { get; set; }
}



[ModelName("eWorld.WebAPI.Params.Exam.Params")]
/// <summary>
/// 检WWW
/// </summary>
public class EParams : s
{
/// <summary>
/// 数据来源
/// </summary>
public string DataSource { get; set; }

}

,加入标记,问题解决
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: