I am working within an earlier application (from 1.1 days) and there are several non-normal collections in it:
[serialable] public class MIFANITY LIST: collectionbase {private int virtual record content; Public int VirtualRecordCount {get {return_virtualRecordCount; } Set {_virtualRecordCount = value; }} Public MyEntityList () {} Public MyEntityList (MyEntity [] arr) {AddRange (arr); } Public MyEntityList [int index] {get {return (MyEntity) innerlist [index]; }} Add Public Zero (MyEntity item) {InnerList.Add (item); } Etc ... I used a normal archive for return type & lt; T & gt; to upgrade a layer of application. This layer is automatically generated and the class names are based on data source table names. Business unit classes are not necessary either, but in this case it is not so. In this case, they perfectly match 1: 1. I tried mapping this type of archive:
archive & lt; MyEntityResponse & gt; Reactions = GetMyEntityResponses (); Automapper.Myper.CreatMap & lt; MyEntityResponse, MyEntity & gt; (); MyEntityList = AutoMapper.Mapper.Map & lt; MyEntityList & gt; (Responses); The most weird thing ... I thought it could be devious on the use of CollectionBase , but I still hit F5. To my surprise, there is no compiler error and no exceptions! However, in the app later threw an exception to complain about a type of conversion from MyEntityResponse to MyEntity when he < Code> Marapier Map Returned from ) at What happened to the new MyEntityList collection was returned but this is MyEntityResponse was filled with objects huh ?? The custom archive overrides the add () method and specifies that the type type should be MyEntity . I want to blow it up while trying to add the wrong type in the archive, but there was no problem working with CollectionBase . So my questions are, if I'm trying to match completely in two ways (property for property), and Automaker had no problems with the collection Buzz, then why do these entries Was not able to map? And why not throw an exception instead of throwing it into the collection incorrectly?
EDIT: I think I know why ... Because there is no one in the non-general collection, the known type is associated with it, as is normal.
I think I got my answer: Non-generic enumerable type, only unmapped, assigned types supported, because the automaker You will be unable to "guess" how you are trying to "map". As shown in the example above, it is not necessary to explicitly configure list types, only their member types.
According to Release 0.2.0, no custom destination archive types are supported.
Comments
Post a Comment