ModelName标记的使用

再项目中出现这样的错误:

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; }

}

,加入标记,问题解决

 

posted @ 2017-03-06 14:42  洛晨随风  阅读(1704)  评论(0编辑  收藏  举报