一、拼
string strSql = @"SELECT t1.TABLE_NAME TableName,t1.TABLE_COMMENT Remark,t1.TABLE_ROWS TableCount,t2.CONSTRAINT_NAME TableKeyName,t2.column_name TableKey FROM information_schema.TABLES as t1 LEFT JOIN INFORMATION_SCHEMA.`KEY_COLUMN_USAGE` as t2 on t1.TABLE_NAME = t2.TABLE_NAME WHERE t1.TABLE_SCHEMA='" + GetDatabase() + "' AND t2.TABLE_SCHEMA='" + GetDatabase() + "'"; if (list != null && list.Count() > 0) { strSql += " AND t1.TABLE_NAME in(" + string.Join(",", list.Select(p => "'" + p.TableName + "'")) + ")";//生成 Where In 条件 }
二 linq
ReceivingNoteCollection items = new Select().From<ReceivingNote>() .Where(ReceivingNote.Columns.BoxNo).In(listWarningData.Select(t=> t.BoxNo).ToArray()) .And(ReceivingNote.Columns.State).IsEqualTo(1) .ExecuteAsCollection<ReceivingNoteCollection>();