Parameter Prompt for all fields in Where, Select, Join?
Posted: Tue 24 Apr 2018 13:41
I'm just getting started with Linq Insight and running into my first issue. When attempting to run 'simpleQuery' below, i'm prompted for not only the query parameter 'ContactID' but also the field in the where clause 'IDContact' and the field from the select 'FirstName'. I don't know the 'FirstName' field, which is what we are querying for, but I'm able to leave that blank and setting both parameters for 'ContactID' and 'IDContact' are required. I know the 'ContactID' value is 1, so I can plug this in for both 'ContactID' and 'IDContact' to get the query to run and Linq Insight returns the correct 'FirstName' of 'Tim'.
Seems odd that I have to enter values for two fields when there is only 1 parameter to this query. But when I add join in to a query, it becomes unusable. Running the below query 'queryWithJoin' prompts for parameters for the fields in each join as well, i know the value for 'detailID', but I don't know the values for the fields used in the join and to enter parameters here would reduce the number of results.
The parameters ContactID and IDContact are required and can't continue without entering a value for them. Is this a limitation of Linq Insight or am I doing it wrong?
Code: Select all
[HttpPost]
public JsonNetResult LingInsight(int ContactID)
{
var simpleQuery = db.Contact.Where(c => c.IDContact == ContactID).Select(c => c.FirstName).FirstOrDefault();
return new JsonNetResult(new { status = "OK" });
}
Seems odd that I have to enter values for two fields when there is only 1 parameter to this query. But when I add join in to a query, it becomes unusable. Running the below query 'queryWithJoin' prompts for parameters for the fields in each join as well, i know the value for 'detailID', but I don't know the values for the fields used in the join and to enter parameters here would reduce the number of results.
Code: Select all
[HttpPost]
public JsonNetResult LingInsight(int detailID)
{
var queryWithJoin = (from detail in db.ContactDetail
join cont in db.Contact on detail.ContactID equals cont.IDContact
where detail.IDContactDetail == detailID
select new { cont.FirstName, detail.DetailValue }).ToList();
return new JsonNetResult(new { status = "OK" });
}
The parameters ContactID and IDContact are required and can't continue without entering a value for them. Is this a limitation of Linq Insight or am I doing it wrong?