public static int ToIntId(this string id) { return int.Parse(id.Substring(id.LastIndexOf('/') + 1)); } public static long ToLongId(this string id) { return long.Parse(id.Substring(id.LastIndexOf('/') + 1)); }
This serves me well in a a lot of cases. Just use it when you're passing values to your ViewModel and use the int/long in your ViewModel.