| SqlExpressionEGetSelectByKeySql Method |
Namespace: LiteRepository
public string GetSelectByKeySql( Type type = null )
Suppose we have a class:
public class User { [SqlKey] public int Id { get; set; } public string FirstName { get; set; } public string SecondName { get; set; } public DateTime Birthday { get; set; } [SqlIgnore] public string FullName { get { return FirstName + " " + SecondName; } } }
If you don't passed any parameter into method, it returns default update SQL:
var sql = GetSelectByKeySql(); // select * from User where Id = @Id;
Passing type you sets subset of columns which you want to update:
var p = new { FirstName = "", SecondName = "" }; var sql = GetSelectByKeySql(type:p.GetType()); // select FirstName, SecondName from User where Id = @Id;