I have a question for you all!!!,
Assume that I have 2 tables, one of them is a parent, and the other is a child. I want to filter the parent table by sending data from the child object. The child table contains 4 columns like
{Id, RuleId, RuleKey, RuleValue}
I send a dictionary as a request that includes value for 2 columns ( RuleKey, RuleValue) of the child object. I want to return the parent object that includes RuleKey and RuleValue I sent.
// Key is the column name of the child table and value is the corresponding value
var dictionary = new Dictionary<string,string>()
{
{"RuleKey", "RuleValue"},
{"RuleKey1", "RuleValue1"}
}
This is what I tried but it obviously won't work and still give the syntax error. These 2 questions about this issue;
1-) How should I do this (Important one:)))))
2-) Will be there any error If I do this In-Memory, If I remember that correctly, EFCore won't translate the LINQ to SQL script because of the memory issues.
var rules = _ruleContext.Rules.AsQueryable();
rules = rules.Where(u => u.Criteria.Where(k => dictionary.Keys.Contains(k.Key) && dictionary.Values.Contains(k.Value)));
public class Rule : Entity<int>
{
public string RuleName { get; set; }
public string Expression { get; set; }
public ICollection<Criteria> Criteria { get; set; }
}
public class Criteria : Entity<int>
{
public int RuleId { get; set; }
public string Name { get; set; }
public string Key { get; set; }
public string Operator { get; set; }
public string Value { get; set; }
public Rule Rule { get; set; }
}