1

I have a table 'Interval' that contain multiple foreign key from "DutationType" Table I have a written a LINQ query like this

var listIntervalDurationType = 
   (from I in oSanEntities.Intervals 
       select new { I.IntervalId, I.IntervalName, I.IntevalTime, 
                    I.DurationType1.TypeName, I.DurationType.TypeName, 
                    I.RetainTime });

But this give the error

An anonymous type cannot have multiple properties with the same name" because of anonymous types are not allow multiple property with same name

For resolve this error I added new property in DutationType entity but there is a mapping error occuring.

What is the solution for that?

1
  • 1
    If you post code, XML or data samples, please highlight those lines in the text editor and click on the "code samples" button ( { } ) on the editor toolbar to nicely format and syntax highlight it! Commented Feb 17, 2011 at 6:34

1 Answer 1

2

Try this:

var listIntervalDurationType = (from I in oSanEntities.Intervals select new {   
I.IntervalId, 
I.IntervalName, 
I.IntevalTime, 
Duration1TypeName = I.DurationType1.TypeName,  
DurationTypeName = I.DurationType.TypeName, 
I.RetainTime });

As message said, you can't have two properties with name TypeName. You should also name Duration1 correctly in database diagram.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.