I have two classes defined as follows:
public class Transaction
{
public int Id { get; set; }
public string Details { get; set; }
}
public class Rule
{
public int Id { get; set; }
public string QueryPattern;
public string Action;
}
There is no direct relationship between these two models within my database. However, the QueryPattern
in the Rule
class includes a SQL LIKE pattern, for example, ‘Hello World%’. I want to compare the Details
in Transaction
with the QueryPattern
in Rule
to retrieve a collection of all transactions along with any applicable rules based on the description.
I have crafted the following SQL statement to achieve this:
SELECT
tr.*,
r.QueryPattern
FROM dbo.Transactions tr
LEFT JOIN dbo.Rules r ON tr.Details LIKE r.QueryPattern
While I can execute this query in SQL successfully, I am having difficulty translating it to LINQ. I haven’t shared my previous attempts due to frequent syntax errors. My goal is to learn LINQ through this process rather than reverting back to SQL.