.NET Fiddle

CSharp · Console

/Program.cs

using System;
using System.Linq;
using System.Collections.Generic;
					
public class Program
{
	public static void Main()
	{
		Console.WriteLine("Hello World");
		var input = new List<MyClass>
		{
			new MyClass { Id = 1, Name = "John", Type = "primary" },
			new MyClass { Id = 2, Name = "John", Type = "secondary" },
			new MyClass { Id = 3, Name = "Joe", Type = "primary" },
			new MyClass { Id = 4, Name = "Jim", Type = "primary" }
		};
		
		var output = input.GroupBy(x => x.Name).Select(x => (x.Count() > 1) ? x.FirstOrDefault(y => y.Type == "primary") : x.FirstOrDefault()).ToList();
		Console.WriteLine(string.Join("\n", output.Select(x => $"Id = {x.Id}, Name = {x.Name}, Type = {x.Type}")));
	}
}

public class MyClass
{
    public int Id { get; set; }
    public string Name { get; set; }
    public string Type { get; set; }
}
;