私はまずCSVファイルを読み込み、datatabel
にデータをロードしてから、そのデータテーブルからsqlテーブルにデータを挿入します。データをSQLテーブルにダンプした後、SQLでデータをフェッチし、多くの句をどこでフィルタリングの目的で使用します。LINQを使用してCSVをSQLのように照会する方法は?
どのようにLINQを使用して、多くのフィルタリング節とCSVファイルを読み込み、データテーブルに結果をダンプすることができますか。
ここで私はdbテーブルにcsvデータをダンプした後、dbテーブルからデータを取得するために使用したsqlを入れています。 SQLはC#アプリケーションで生成されます。
strSql = "select (select count(*) as incoming from " + tableName + " where direction='I' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) >='" + StartTime + "' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) <='" + EndTime + "' ";
strSql = strSql + "and Is_Internal=0 and continuation=0 and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' ";
strSql = strSql + "and party1name not in ('Voice Mail') and party1name not like 'VM %') as incoming, ";
strSql = strSql + "(select count(*) as OutGoing from " + tableName + " ";
strSql = strSql + "where direction='O' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) >='" + StartTime + "' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) <='" + EndTime + "' ";
strSql = strSql + "and Is_Internal=0 and continuation=0 and party1name not in ('Voice Mail') ";
strSql = strSql + "and party1name not like 'VM %') as OutGoing, ";
strSql = strSql + "(select count(*) as CallTransfer from " + tableName + " ";
strSql = strSql + "where continuation=1 and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) >='" + StartTime + "' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) <='" + EndTime + "' ";
strSql = strSql + "and RIGHT(convert(varchar,[call duration]),8)<> '00:00:00' and party1name not in ('Voice Mail') ";
strSql = strSql + "and party1name not like 'VM %') as CallTransfer; ";
strSql = strSql + "SELECT count(*) as UnansweredCalls_DuringBusinessHours from "
+ tableName + " where direction='I' and " + Environment.NewLine;
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) >='" + StartTime + "' and ";
strSql = strSql + "CONVERT(datetime,right([Call Start],8)) <='" + EndTime + "' ";
strSql = strSql + "and RIGHT(convert(varchar,[call duration]),8)= '00:00:00' and [Ring duration]>0 " + Environment.NewLine;
//strSql = strSql + "CONVERT(Varchar,CONVERT(datetime,[Call Start]),108) between '09:00:00' and '17:30:00' " + Environment.NewLine;
strSql = strSql + "and party1name not in ('Voice Mail') and party1name not like 'VM %' and party1name not like 'Line%'" + Environment.NewLine;
はそう誰もが、SQLを見て、私はLINQで同じ句クエリcsvファイルを使用する方法を教えてください。
私はcsvファイルを読み込み、csvファイルのデータをクエリするために必要なコードを表示してください。ご案内ください。おかげ
リンクのみの回答は推奨されません(ただし、あなたは6年間メンバーになっています)。おそらく、その図書館の質問者の問題を解決することを目的とした例を投稿することができますか? –
確かに - はい、私は正確なことについて謝罪することさえ知られています。 –
どのように句を適用する私は私のSQLでlinqのcsvのために使用するときに使用? –