TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chris Campbell
NA
4
8.1k
How can I rewrite this LINQ to Entities query without getting the Parameterless Constructors error
Aug 14 2012 3:10 AM
Hello,
I am matching Condo records to rental transactions or rather fixing an application that does.
- MatchFields is a class that inherits from an Abstract class which has an AutoMatic Property of type Condominium
- There is also a Condominium dBSet in the Context repository as well as a Class object Condomium. The syntax highlighted is as follows
"ReadWriteProperty_OfType_Condominium_Of_Class_ThatIheritsThePropertyFrom_an_AbstractClass = new CondominiumClassObject_OfType_Condominium(condoRecord_from_DbSet_ContextObject),"
I apologize if that is not very clear, unfortunately I can only give abstract info, not actual data here as I am prohibited under contract. Here is the exact Method below:
private static List<MatchFields> GetMatchRecords(dBContextContainer context)
{
List<MatchFields> match = (from condoRecord in context.Records
from transRecord in context.ManyToManyResultMatch
where
condoRecord.Area == transRecord.Area &&
condoRecord.Address == transRecord.Address &&
condoRecord.AptNo == transRecord.AptNo
select
new MatchFields()
{
Condominium = new Condominium(condoRecord),
MatchRecords = transRecord,
//MatchRecords contains data I have not figured out yet
}).Load();
LoadCondoResult(context);
return match;
}
I am trying to fix a bug made by a previous developer on a project and I'm very new to LINQ and EntityFramework. The issue I'm running into is that on "Condominium = new Condominium(condoRecord),..." I get the fabled error "Only parameterless constructors and initializers are supported in LINQ to Entities" My problem resides in the fact that I understand the error message and its nature I do not know the syntax well enough to resolve the problem because I cannot visualize the solution. I've been fixing bugs left and right. Can anybody help me out here? I'm really stuck.
Reply
Answers (
3
)
How do I translate this mssql query to LINQ syntax? I cant really get it when I have several where clauses:
OVER SqlFunction with LINQ