Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Map reference not found C# [closed]

Tags:

c#

automapper

while (rdr.Read())
{
    List<PackageDetailFile> pkgFiles = rdr.AutoMap <PackageDetailFile> ().ToList(); 
    foreach (PackageDetailFile pkgf in pkgFiles)
    {
         PackageDetail pkgd = getPackageDetail((long)pkgf.PackageDetailId);
    }

I have an error like:

'System.Data.SqlClient.SqlDataReader' does not contain a definition for 'AutoMap' and no extension method 'AutoMap' accepting a first argument of type 'System.Data.SqlClient.SqlDataReader' could be found (are you missing a using directive or an assembly reference?)

and I can't find the AutoMap reference.

like image 432
paxcow Avatar asked Feb 15 '26 02:02

paxcow


1 Answers

The simple answer is to add a reference to the AutoMapper library. How you do that, you can easily find out if you search. I'll help you on your way: http://msdn.microsoft.com/en-us/library/wkze6zky(v=vs.100).aspx has a rather full-length exhaustive how-to, and https://stackoverflow.com/a/2157158/64976 is a more concise answer to a question about how to add references.

A more extended answer would perhaps be to suggest that you return to the basics of the AutoMapper documentation, .NET development and project structure and learn how to add a reference to a downloaded, third party assembly. http://automapper.org/ is a good place to start for information on AutoMapper itself.

like image 171
J. Steen Avatar answered Feb 16 '26 14:02

J. Steen