I have known about the use of SqlMethods.Like(...) for a while, but only recently realized a better way after reading another's code. Here's the SqlMethods.Like() way:
list.Where(o => SqlMethods.Like(o.Name, "%" + Name + "%"))Here is that same statement more appropriately expressed:
list.Where(o => o.Name.Contains(Name))Clever eh? Just like I'd bake it if I were using LinqToObject. Now I'm not constrained to the LinqToSql context. Good news continues with the string class' .StartsWith(...) and .EndsWith(...) methods working exactly as one might expect.
This also goes to show just how far the LinqToSql team went to blend into the Linq paradigm.
1 comment:
you said giggle with glee. My day, made.
Post a Comment