Click or drag to resize
SqlExpressionEGetDeleteSql Method
Creates a DELETE SQL based on the passed parameters.

Namespace: LiteRepository
Assembly: LiteRepository (in LiteRepository.dll) Version: 2.0.4
Syntax
C#
public string GetDeleteSql(
	Expression<Func<E, bool>> where = null,
	Object param = null
)

Parameters

where (Optional)
Type: System.Linq.ExpressionsExpressionFuncE, Boolean
Where expression. You can use members of E or param. Other values will be evaluated.
param (Optional)
Type: SystemObject
Query parameters.

Return Value

Type: String
A string with a delete query.
Examples

Where expression used like in GetSelectSql. But if you don't pass where expression, method returns SQL with where condition to delete item by key.

Suppose we have a class:

C#
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; } }
}

Then you call method without parameters:

C#
var sql = GetDeleteSql();
// delete from User where Id=@Id;
See Also