MVC development errors, type exceptions in C #

Source: Internet
Author: User

Cats are known to have cats, dogs and dogs, and cats cannot produce dogs. The same entity is a strongly-typed relationship that often causes errors due to typing errors. Nothing but 1.1 points of the exclusion of the wrong, but Viewmodle, you will go to see it?

There is an error called "automapper.automappermappingexception" type exception occurs in AutoMapper.dll, but not in user code ", can also be called" Missingtype map Configuration or unsupported mapping ", anyway, is type mismatch.

This is a method in Staticcontentbll, the type is staticcontent, but when the error is displayed, the type is the category type. Nani?

        <summary>///query static content (public)///</summary>//<param name= "CategoryID" > Root By category query static content (public) </param>////<returns> return static content viewmodle</returns> publicly LIST&LT;STATICCONTENTV            Iewmodel> querystaticcontent (Staticcontentviewmodel encategory, int pageSize, int pageIndex, out int. total) { Call the underlying, query staticcontent collection generic list<staticcontent> liststaticcontent = this. Currentdal.loadpageitems (PageSize, pageIndex, out total,p = P.categoryid = Encategory.categoryid, p = p. TimeStamp, False).            ToList ();            Create conversion rules, convert entities Mapper.createmap<staticcontent, staticcontentviewmodel> (); var liststaticcontentvm = Mapper.map<list<staticcontent>, list<staticcontentviewmodel>> (            Liststaticcontent);                  Return query result return LISTSTATICCONTENTVM; }
The last-hammered error is in Viewmodle. Viewmodle things are generally derived from the model directly, including the various attributes and foreign keys, as follows:

    <summary>//static content table, storage organization settings, Unit introduction, etc.///</summary> [DataContract] public partial class Static        Contentviewmodel {//<summary>///static Content ID//</summary> [DataMember]        Public System.Guid Staticcontentid {get; set;} <summary>///static content topics///</summary> [DataMember] public string Staticcontentti        tle {get; set;} <summary>//static content content///</summary> [DataMember] public string Staticcontentco        ntent {get; set;} <summary>//Pictures///</summary> [DataMember] public string Images {get; set; }///<summary>//time stamp///</summary> [DataMember] public System.DateTime        TimeStamp {get; set;} <summary>///Add Person ID///</summary> [DataMember] public system.guid Userguid { Get SeT }///<summary>///Category ID///</summary> [DataMember] public System.Guid Cat        Egoryid {get; set;}  <summary>///Navigation Properties-category///</summary> public virtual Categoryviewmodel category {get; Set }///<summary>//Navigation Properties-User information///</summary> public virtual Userinfoviewmodel user    Info {get; set;} }
Viewmodle is the business domain data, should not be placed foreign key, put the foreign key is equal to introduce another type, so the final type is mixed. Well, that's what I understand.

MVC development errors, type exceptions in C #

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.