In my query I need to return instances of a class that doesn't have a default constructor (specifically this is in a custom Membership provider, and MembershipUser is the culprit)
var users = from l in context.Logins
select new MembershipUser(
Name,
l.Username, // username
l.Id, // provider key
l.MailTo,
l.PasswordQuestion,
l.Notes.FirstOrDefault().NoteText,
l.IsApproved,
l.IsLockedOut,
l.CreatedOn,
l.LastLoginOn.HasValue ? l.LastLoginOn.Value : DateTime.MinValue,
l.LastActivityOn.HasValue ? l.LastActivityOn.Value : DateTime.MinValue,
DateTime.MinValue,
l.LastLockedOutOn.HasValue ? l.LastLockedOutOn.Value : DateTime.MinValue
);
is syntacitally correct, but results in a runtime error as Only parameterless constructors and initializers are supported in LINQ to Entities.