0
SELECT * FROM register WHERE user_id LIKE 'a%'

SELECT * FROM register WHERE user_id LIKE '%m'

SELECT * FROM register WHERE user_id LIKE '%andru%'


SELECT R.name,C.country_name,S.state_name 
FROM register R JOIN country C ON R.country_id=C.country_id
JOIN state S  ON R.state_id=S.state_id

SELECT R.name,C.country_name,S.state_name 
FROM register R INNER JOIN country C ON R.country_id=C.country_id       
INNER JOIN state S ON R.state_id=S.state_id

现在我需要LinqToSql查询而不是这些查询

4

1 回答 1

1
var result = context.Registers.Select(x => x.StartsWith(foo)).ToList();

result = context.Registers.Select(x => x.EndsWith(foo)).ToList();

result = context.Registers.Select(x => x.Contains(foo)).ToList();

result = from register in context.Registers
         join state in context.States on register.state_id equals state.state_id
         select new { register.name, state.country_name, state.state_name }

注意,inner join功能join相同SQL——因此无需复杂化。

于 2012-07-02T17:25:03.903 回答