1
public List<ProjectImpacts> getProjectImpactsByProjeactIDAndImpactName(String prefe , String impcName)
{ 
    String xim =  cecbContext.Impacts.First(i=>i.impt_name.Contains(impcName)).impt_reference;

    IQueryable<ProjectImpacts> query = from c in cecbContext.ProjectImpacts
            join b in cecbContext.Impacts on c.impt_reference equals b.impt_reference             
            where c.proj_reference == prefe && c.impt_reference == xim
            select b.impt_name;

    List<ProjectImpacts> SelectedImpacts = query.ToList(); //query.Select(refe => new ProjectImpacts { impt_reference =   }).ToList();

    return SelectedImpacts;
}

I'm getting an error in this query:

Cannot implicitly convert type 'System.Linq.IQueryable' to 'System.Linq.IQueryable'. An explicit conversion exists (are you missing a cast?)

0

1 Answer 1

3

This is because your query selects a name at the end:

IQueryable<ProjectImpacts> query = from c in cecbContext.ProjectImpacts
    join b in cecbContext.Impacts on c.impt_reference equals b.impt_reference             
    where c.proj_reference == prefe && c.impt_reference == xim
    // select b.impt_name; // <<== Replace this...
    select c;              // <<== with this.

The type parameter T of the generic IQueryable<T> corresponds to the type of the object selected in the query. Since you select a name (which is presumably a string), you got an IQueriable<string>. Once you select c, which is ProjectImpacts, you'd get IQueryable<ProjectImpacts> as your result

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

1 Comment

@Gayashan It looks like ProjectImpacts is c, not b; b is Impacts. Try the changed query and see if it helps.

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.