Skip to content

Instantly share code, notes, and snippets.

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);
public class UserModel
{
public string Name;
public string Age;
public string City;
}
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();
var departments = new List<Department>();
foreach(var user in users)
{
departments.AddRange(user.Departments);
}
@pparadis
pparadis / user.cs
Last active September 8, 2015 09:50
User
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; }
@pparadis
pparadis / dd.py
Created August 13, 2015 10:00
Deep Dream
# 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
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)
@pparadis
pparadis / distinct.cs
Last active August 29, 2015 14:24
Distinct
class Program
{
static void Main(string[] args)
{
var users = new List<User>
{
new User
{
FirstName = "Pascal",
LastName = "Paradis",
namespace FrenchCoding.Consume
{
using Obsolete;
using System.Collections.Generic;
public class UserSearchEngine
{
public List<string> SearchUsers(string query)
{
var directory = new UserDirectory();
using System.Collections.Generic;
namespace FrenchCoding.Obsolete
{
public class UserDirectory
{
public List<string> GetAllUsers()
{
return new List<string>();
}