Skip to content

Instantly share code, notes, and snippets.

View binding.cs
foreach (ModelError error in modelState.Errors.Where(err => String.IsNullOrEmpty(err.ErrorMessage) && err.Exception != null).ToList())
{
for (Exception exception = error.Exception; exception != null; exception = exception.InnerException)
{
// We only consider "known" type of exception and do not make too aggressive changes here
if (exception is FormatException || exception is OverflowException)
{
string displayName = propertyMetadata.GetDisplayName();
string errorMessageTemplate = GetValueInvalidResource(controllerContext);
View model.cs
public class UserModel
{
public string Name;
public string Age;
public string City;
}
View select-many-with-parent.cs
var results = users.SelectMany(p => p.Departments, (user, departement) => new Tuple<string, string>(user.Name, departement.Name));
foreach(var userAndDepartment in results)
{
Console.WriteLine(string.Format("User: {0} - Department: {1}", userAndDepartment.Item1, userAndDepartment.Item2));
}
Console.ReadKey();
View depts-for.cs
var departments = new List<Department>();
foreach(var user in users)
{
departments.AddRange(user.Departments);
}
View user.cs
public class User
{
public Guid Id { get; set; }
public string Name { get; set; }
public List<Department> Departments { get; set; }
}
public class Department
{
public Guid Id { get; set; }
View dd.py
# imports and basic notebook setup
from cStringIO import StringIO
import numpy as np
import scipy.ndimage as nd
import PIL.Image
from IPython.display import clear_output, Image, display
from google.protobuf import text_format
import caffe
View user.cs
public class User
{
public string FirstName { get; set; }
public string LastName { get; set; }
public LoginInformation LoginInformation { get; set; }
public class Comparer : IEqualityComparer<User>
{
public bool Equals(User x, User y)
View distinct.cs
class Program
{
static void Main(string[] args)
{
var users = new List<User>
{
new User
{
FirstName = "Pascal",
LastName = "Paradis",
View UserSearchEngine.cs
namespace FrenchCoding.Consume
{
using Obsolete;
using System.Collections.Generic;
public class UserSearchEngine
{
public List<string> SearchUsers(string query)
{
var directory = new UserDirectory();
View UserDirectory.cs
using System.Collections.Generic;
namespace FrenchCoding.Obsolete
{
public class UserDirectory
{
public List<string> GetAllUsers()
{
return new List<string>();
}