小编And*_*rew的帖子

如何检查列表列表是否包含另一个列表

我想创建一个包含两个 int 值的列表,假设它arrfirst和另一个包含 列表的列表arrfirst,假设它arrsecond然后检查是否arrsecond包含定义的arrfirst。现在我创建了列表,但是当我尝试使用它时.Contains它不起作用。

List<List<int>> Eklenenler = new List<List<int>>();

for (int i = 0; i < YourTable.Rows.Count; i++)
        {
            prjAd = YourTable.Rows[i].Field<string>("F1");
            if (prjAd != "Servis Adresi")
            {
                wesAd = YourTable.Rows[i].Field<string>("F2");
                RowPrj = tbProjeler.AsEnumerable().Where(r => r.Field<string>("prjAd") == prjAd).FirstOrDefault();
                RowWes = tbServisler.AsEnumerable().Where(k => k.Field<string>("wesAd") == wesAd).FirstOrDefault();
                prjId = RowPrj.Field<int>("prjId");
                wesId = RowWes.Field<int>("wesId");
                List<int> temp = new List<int>();
                temp.Add(prjId);
                temp.Add(wesId);
                if (!Eklenenler.Contains(temp))
                {
                    sqlExProjeEkle = "INSERT INTO NLK_PRJ_Webservisler (prjId,wesId) Values …
Run Code Online (Sandbox Code Playgroud)

c# list

1
推荐指数
1
解决办法
2288
查看次数

有效的WHERE子句检查minumim和NULL之间的值

我有一个SQL查询,该查询根据租金的持续时间返回价格水平。该表包含以下列:

ProductID (UNIQUEIDENTIFIER), MinDuration(INT), MaxDuration(INT), Price (DECIMAL(10, 4)
Run Code Online (Sandbox Code Playgroud)

我当前使用的查询的简化版本是:

SELECT Price
FROM RentalPrices
WHERE ProductID = @ProductID
  AND @Duration BETWEEN MinDuration AND MaxDuration;
Run Code Online (Sandbox Code Playgroud)

表例

+--------------------------------------+-------------+-------------+-------+
|              ProductID               | MinDuration | MaxDuration | Price |
+--------------------------------------+-------------+-------------+-------+
| e93d19e1-142f-41cc-8f39-9cf7607717ac |           0 | 3           |    25 |
| e93d19e1-142f-41cc-8f39-9cf7607717ac |           4 | 7           |    50 |
| e93d19e1-142f-41cc-8f39-9cf7607717ac |           8 | 14          |   100 |
| e93d19e1-142f-41cc-8f39-9cf7607717ac |          15 | 30          |   200 |
| e93d19e1-142f-41cc-8f39-9cf7607717ac |          31 | NULL        |   500 | …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server

1
推荐指数
1
解决办法
134
查看次数

"Flatten"将<Tuple << T>,<T >>>列入List <T>

我有一个元组列表,元组中的对象都是相同的类型.在我们进行错误处理之前,需要一个元组列表的数据结构.为了优化错误处理,我想将元组展平为单个列表以允许重复检查:

例如,如果我有List<Tuple<string,string>>()(我的类型更复杂但想法应该成立):

[<"Tom","Dick">, <"Dick","Harry">, <"Bob","John">]

我想最终得到:

["Tom", "Dick", "Harry", "Bob", "John"]

我知道我可以这样做:

List<string> stringList = List<string>();
Foreach(var item in tupleList){
  stringList.Add(item.Item1);
  stringList.Add(item.Item2);
}
stringList = stringList.Distinct();
Run Code Online (Sandbox Code Playgroud)

但我希望有一种更有效的方式,也许是Linq内置的东西.不能保证重复,但由于错误处理的性能成本,我宁愿只处理一次.

c# linq performance

0
推荐指数
1
解决办法
432
查看次数

无法理解以下查询,有人解​​释一下吗?

select table_name, 
to_number(
  extractvalue(
    xmltype(
      dbms_xmlgen.getxml(
       'select count(*) c from '||table_name
    ))
  ,'/ROWSET/ROW/C')
) count
from user_tables
order by table_name;
Run Code Online (Sandbox Code Playgroud)

我知道它给出了每个表的行总数。但如何知道它是如何工作的呢?

sql oracle

0
推荐指数
1
解决办法
198
查看次数

标签 统计

c# ×2

sql ×2

linq ×1

list ×1

oracle ×1

performance ×1

sql-server ×1

t-sql ×1