我的主键中有一个包含3列的表.如何检查特定ID是否存在?
我知道一个主键......但我不知道很多!
public bool Check(string id)
{
return (from eee in Db.table where eee.id == id select eee).Any();
}
Run Code Online (Sandbox Code Playgroud)
如果你有一个复合键
public bool Check(string key1, string key2, string key3) {
return Db.table.Any(x => x.key1== key1 && x.key2 == key2 && x.key3 == key3);
}
Run Code Online (Sandbox Code Playgroud)