How to ignore all unmapped properties using Automapper in C# and VB.NET

To ignore all unmapped properties using Automapper in C# and VB.NET you can use the following snippet.

Sample C#

var testClassA = new TestclassA() {Name = "Testname", Title = "Testtitle"};
Mapper.CreateMap<TestclassA, TestclassB>().ForAllMembers(opt => opt.Ignore());
Mapper.CreateMap<TestclassA, TestclassB>().ForMember(source => source.Title, destination => destination.MapFrom(x => x.Title));

var testClassB = Mapper.Map<TestclassA, TestclassB>(testClassA);
Console.WriteLine(testClassB.Title); //prints out "Testtitle"
Console.WriteLine(testClassB.Name); //print nothing  (NULL)

Sample VB.NET

Dim testClassA = New TestclassA() With { _
	Key .Name = "Testname", _
	Key .Title = "Testtitle" _
}
Mapper.CreateMap(Of TestclassA, TestclassB)().ForAllMembers(Function(opt) opt.Ignore())
Mapper.CreateMap(Of TestclassA, TestclassB)().ForMember(Function(source) source.Title, Function(destination) destination.MapFrom(Function(x) x.Title))

Dim testClassB = Mapper.Map(Of TestclassA, TestclassB)(testClassA)
Console.WriteLine(testClassB.Title)
'prints out "Testtitle"
Console.WriteLine(testClassB.Name)
'print nothing  (NULL)

How to open a pdf at a named destination using AcroRd32Info in C# and VB.NET

To open a pdf at a specific page using AcroRd32Info in C# and VB.NET you can use the following snippet.

Sample C#

public static void OpenPdfAtNamedDestination(string document, string namedDestination)
{
    object myProcess = new Process();
    object startInfo = new ProcessStartInfo();
    startInfo.FileName = "AcroRd32Info.exe";
    startInfo.Arguments = string.Format(" /n /A \"pagemode=bookmarks&nameddest={0}\" \"{1}\"", namedDestination, document)
    myProcess.StartInfo = startInfo;
    myProcess.Start();
}

Sample VB.NET

Public Shared Sub OpenPdfAtNamedDestination(document As String, namedDestination As String)
    Dim myProcess As Object = New Process()
    Dim startInfo As Object = New ProcessStartInfo()
    startInfo.FileName = "AcroRd32Info.exe"
    startInfo.Arguments = String.Format(" /n /A ""pagemode=bookmarks&nameddest={0}"" ""{1}""", namedDestination, document)
    myProcess.StartInfo = startInfo
    myProcess.Start()
End Sub