PCだい「ちゅき」

気がつけば庶事手伝い

目次

Blog 利用状況

ニュース

・H24/01/02
 Microsoft MVPを受賞しました
・H23/11/18
 MCTの憂鬱さんと相互リンクを張っていただきました^^
・H23/09/10
 プログラミング生放送でスピーカーさせていただきました^^ ・H22/12/18
 わんくま同盟でスピーカしました^^
さて、来年はどんな年になるかな。予想が当たるといいなぁ。
・H22/07/17
 わんくま同盟でスピーカしました^^
技術系のセッションは久しぶり。VB! VB!
・H22/03/13
 Tech FieldersでLTのスピーカしました^^
・H21/12/12
 わんくま同盟でスピーカしました^^
最近はずっとLT担当だったので、ちょっと新鮮でした^^
・H20/11/18
 Tech Fielders セミナー 大阪の
 Lightning Talkで優勝しました^^
・H20/8/23
 わんくま同盟で2回目のスピーカしちゃいました
 WCFと戯れてみました^^
・H20/5/17
 わんくま同盟でスピーカしちゃいました^^
 ちゃんとスピーカー持参しましたよんw
・H20/2/22
 なめ猫の参加証もらいました^^
・H20/1/22
 テンプレートを変えてみました^^
・H19/7/23
 ACEプログラムで、ナップサックをもらった上、工具セットももらえることになりました^^
・H19/1/11
 1が並ぶ縁起の良い日に投稿開始!。今後ともお付き合いよろしくお願いします
・H18/10/29
 参加させていただきました^^
ド・初心者ですがどうぞよろしくお願いします。

↓うーん、仕事しろ^^;
Chukiの脳内メーター

Chukiの脳内メーター

書庫

日記カテゴリ

ギャラリ

コミュニティ

相互リンク

UiPathで"LINQ to DataSet”を使いたい!

ここ最近、UiPathでイロイロ遊んでます。そこでUiPath (ja) Advent Calendar 2018に参加してみました。

UiPathって、.NET使いなら見た瞬間あれもこれもしたくさせたくなるRPA製品だったりします。
かなり良くできていて、そのままでも十分使えるのですが、少しでも.NETを使ったことのある方ですと、.NETのアセンブリを使って、もっといろんなことがしたくなるはずです。勉強用や個人用だとタダで使えたりしますので皆さんもぜひ遊んでみてください。(詳しくはちゃんとライセンス条項読んだって下さい、責任なんて取れませんw)

本題

さて、皆さんDataTableの扱いどうされていますか?
現在は Entity Framework に押されて微妙な立場ですが、DataSet ではインメモリ DB を目指してたのでは?と思えるほどがっつりイロイロできます。UiPathは、ExcelのシートやCSVをDataTableに取り込めるのでDataTableをゴニョゴニョできるとすごく便利です。

そんな私に DataTable を SQL 文ライクでゴニョゴニョできる「LINQ for DataSet」はすごく便利です。
UiPathでは、データテーブル関連の部品が増えてきていますが、やっぱりLINQ使えると開発効率が全く違います。

ということで、LINQ for DataSetを使って遊んでみましょう

UiPathでLINQ to DataSetを使ってみる

1.準備

LINQ to DataSetで必要な.NETのアセンブリは次の二つです。

  • System.Data
  • System.Data.DataSetExtensions

早速使ってみましょう・・・ 無いorz

まぁ、アセンブリ参照の追加はいつものことなので、さっそく追加・・・ GUIが無いorz


■LINQ to DataSetを使うための準備

「UiPath.Web.Activities」をパッケージから追加する。そうすると、上記アセンブリが参照されて LINQ to DataSet が使えるようになります。

■開発者、というか保守まで考えてる人向け

欲しいアセンブリだけ入れれば良い。パッケージ追加は邪道!という個別参照追加命!な方へ

● UiPath で参照を手動追加、または参照しているアセンブリを確認する方法(実は一番ブログに残しておきたかったの、これかもしれない^^;)
1)追加したいワークフローの XMAL ファイルを、テキストエディタで開く
2)アセンブリ一覧を確認。必要なアセンブリがなければ追加する。
   <TextExpression.ReferencesForImplementation>
     <sco:Collection x:TypeArguments="AssemblyReference">
       <AssemblyReference>System.Activities</AssemblyReference>
       (中略)
       <AssemblyReference>System.Data.DataSetExtensions</AssemblyReference>
3)保存
※いうまでもなく、アセンブリが足りないというエラーが出たときは、XAMLファイル開いてアセンブリを確認するよりも前にパッケージの有無やバージョンを確認しましょう


2. LINQ to DataSetの使い方

山ほど出てくるからググレ!(あ、終わった・・・)

せっかくなので、ちゃんとUiPathで動くか確認してみましょう。
以下、サンプルデータはこの投稿の最後にあるものをUTF-8形式のCSVで保存して使ってます

1) いわゆるWHERE句で検索

では、データから私「ちゅき」の行を取得してみましょう。

○代入(Assign)アクティビティ
左辺 (DataRow型):dr
右辺:From row In dt Where row("名前").ToString = "ちゅき"

はい、ビックリマーク来た

image_thumb1

下表では「ちゅき」は一意ですが、実際はいくつ返されるかわかりません。
そのため、受ける変数はコレクションである必要があります。

結果が一つしかないことが分かっている場合は上側、複数ある時は下側のように書きましょう

○代入(Assign)アクティビティ
左辺 (DataRow型):dr
右辺:(From row In dt Where row("名前").ToString = "ちゅき" ).FirstOrdefault()

○代入(Assign)アクティビティ
左辺 (System.DataEnumerableRowCollection<DataRow>型):dr
右辺:From row In dt Where row("名前").ToString = "ちゅき"


2) WHERE句で遊んでみる

当たり前ですが、こういう書き方もできたりします。ただ、いきなりString型にできず、いったんObject型になります。このあたり、褒貶毀誉があるLINQ to DataSetのバカかアホかと怒られる理由だったりします。

○代入(Assign)アクティビティ
左辺 (System.DataEnumerableRowCollection<Object>型):names
右辺:From row In dt Where row("住所").ToString.SubString(0,3) = "福岡県" Select row("名前")

取り出した namesはこんな感じで使えるので、イメージ通りだと思います。

image_thumb

取り出したデータを Count メソッドで数えればデータ個数なんかもすぐにとってこれます。


3)ほかにもいっぱいSQL文っぽいやつ

使える句はこんな感じです。ただ、思いっきりデータを展開して結合したりするので、あんまりえげつないことをするとメモリがパンクするかも・・・。まぁ、オンメモリDBがメモリイーターなのはご存知の通りですね^^;

クエリ一覧

Aggregate 句
Distinct 句
Equals 句
From 句
Group By 句
Group Join 句
Join 句
Let 句
Order By 句
Select 句
Skip 句
Skip While 句
Take 句
Take While 句
WHERE 句


最後に

LINQ使えるようになると、DataTableに限らず、VBでイロイロ記述できるようになるので是非のぞいてみてください。
UiPath開発者の必須項目になるかも・・・。


表.各地の勉強会でなんかあったらお世話になるところ

-- list.csv---
名前,郵便番号,住所,電話番号
中,100-8929,東京都千代田区霞が関2丁目1番1号,03-3581-4321
とっちゃん,231-0002,横浜市中区海岸通2丁目4番,045-211-1212
ちゅき,540-8540,大阪市中央区大手前三丁目1番11号,06-6943-1234
You & I,460-8502,名古屋市中区三の丸2-1-1,052-953-9110
むたぐち,650-0011,神戸市中央区下山手通5丁目4番1号,078-341-7441
ゆーち,812-8576,福岡県福岡市博多区東公園7-7,092-641-4141
どらん,803-0811,福岡県北九州市小倉北区大門1丁目6?19,093-583-1110

投稿日時 : 2018年12月13日 22:00

Feedback

# Thɑnks to my father ѡho informed me on the topic of tһіs webpage, this blog iss гeally awesome. 2018/12/13 11:37 Tһanks tto mү father wһo informed mе on thee tkpic

Thanks tо my fatherr ?ho informed mе on thhe topic off
thi? webpage, th?? blog iss rеally awesome.

# You need tо take pаrt іn a contest for ᧐ne of the finest websites on tһe net. I most cеrtainly ᴡill recommend tһis web site! 2018/12/15 21:39 Үoᥙ neеd to takе paгt inn ɑ contest f᧐r one of th

You neеd to take paгt ?n a contest for one of the
finest websites on t?e net. I mo?t certаinly will recommend t?is web site!

# It's fantastic tһat yyou are ɡetting iideas frοm tһis piece of writing as weⅼl as from our dialogue made at thiѕ time. 2018/12/17 20:40 It's fantastic tһаt youu arе getting ideas from t

?t'sfantastic thаt you are getting ideas from
this piece ?f writing as wel? ?s fгom ?ur dialogue madе at t?is t?me.

# I seriously love your website.. Great colors & theme. Did you make this website yourself? Please reply back as I'm attempting to create my own blog and would love to know where you got this from or exactly what the theme is called. Cheers! Greetings 2018/12/19 21:44 I seriously love your website.. Great colors &

I seriously love your website.. Great colors & theme.
Did you make this website yourself? Please reply back as I'm attempting to
create my own blog and would love to know where you got this from or
exactly what the theme is called. Cheers! Greetings! Very helpful advice in this particular article!
It is the little changes which will make the largest changes.

Thanks for sharing! I couldn't refrain from commenting.
Well written! http://foxnews.co.uk/

# FAKqjmbDHtlrKeM 2018/12/21 5:34 https://www.suba.me/

g6KI54 This is a really good tip particularly to those fresh to the blogosphere. Simple but very accurate info Appreciate your sharing this one. A must read article!

# I've been exploring for a little bit for any high quality articles or blog posts in this kind of house . Exploring in Yahoo I at last stumbled upon this web site. Reading this info So i'm satisfied to exhibit that I've a very excellent uncanny feeling I 2018/12/27 3:57 I've been exploring for a little bit for any high

I've been exploring for a little bit for any high quality articles or blog posts in this kind of house .
Exploring in Yahoo I at last stumbled upon this web site.
Reading this info So i'm satisfied to exhibit that I've a very
excellent uncanny feeling I discovered just what I needed.
I such a lot without a doubt will make certain to don?t disregard this website and give it a glance on a constant
basis.

# OugRzdRvbuIntoUd 2018/12/27 7:27 http://shreevighnahartahospital.in/index.php?optio

When some one searches for his essential thing, therefore he/she wants to be available that in detail, so that thing is maintained over here.

# AwxMPAGjXKEgbAMb 2018/12/27 12:28 http://bormebel.com/bitrix/rk.php?goto=http://www.

Very neat blog article.Thanks Again. Awesome.

# KGPRnoikVtjAnpMTrSZ 2018/12/27 15:55 https://www.youtube.com/watch?v=SfsEJXOLmcs

You need to participate in a contest for the most effective blogs on the web. I all recommend this site!

# qwEbihQkOvrVpdBcSNY 2018/12/28 9:11 http://commaflight77.cosolig.org/post/the-best-pla

Looking for me, I came here for important information. The information is so incredible that I have to check it out. Nevertheless, thanks.

# QRRmTufMBnkz 2018/12/28 12:04 https://www.bolusblog.com/

Im grateful for the post.Thanks Again. Great.

# qmZkNAqfKklEzP 2018/12/28 18:56 https://www.eenjaarover.nl/recept/vegan-recept-zoe

This is one awesome blog post.Thanks Again. Want more.

# NxMdXrtQCbaovdh 2018/12/28 20:40 http://davethewriter.com/__media__/js/netsoltradem

There as definately a great deal to know about this subject. I like all the points you have made.

# jMUaFPcsZzXeZ 2018/12/29 1:45 http://www.bpcitigroupcenter.com/__media__/js/nets

Merely wanna admit that this is extremely helpful, Thanks for taking your time to write this.

# UVfVhtcZMBiTW 2018/12/29 3:29 http://schlogger.com/hamptonbaylighting

Wow, that as what I was seeking for, what a data! present here at this weblog, thanks admin of this website.

# Heya i'm for the primary time here. I found this board and I find It truly useful & it helped me out a lot. I am hoping to give one thing back and aid others like you helped me. 2018/12/29 14:23 Heya i'm for the primary time here. I found this b

Heya i'm for the primary time here. I found this board and I find It truly useful &
it helped me out a lot. I am hoping to give one thing
back and aid others like you helped me.

# Hi there i am kavin, its my first time to commenting anywhere, when i read this paragraph i thought i could also create comment due to this brilliant article. 2019/01/01 19:04 Hi there i am kavin, its my first time to comment

Hi there i am kavin, its my first time to commenting anywhere, when i read this paragraph i thought i could also create comment due to this
brilliant article.

# cTZWuhyzpUSDws 2019/01/02 21:50 http://onlinemarket-manuals.club/story.php?id=575

Man I love your posts, just can at stop reading. what do you think about some coffee?

# FGjfINIzRvJUz 2019/01/03 3:39 http://www.rueckwald.info/__media__/js/netsoltrade

Some truly prime blog posts on this web site , saved to favorites.

# tzAMQmJKzm 2019/01/03 22:32 http://microbiology.med.uoa.gr/index.php?option=co

Thanks for sharing, this is a fantastic blog post. Want more.

# nzllrcVYNz 2019/01/04 21:08 https://ghostshoe90.hatenablog.com/entry/2019/01/0

This blog is really awesome and diverting. I have found many helpful stuff out of it. I ad love to return again soon. Cheers!

# PjZvNlfMVJXWCppabd 2019/01/05 14:24 https://www.obencars.com/

Well My spouse and i definitely enjoyed studying the idea. This idea procured simply by you is very constructive forever planning.

# yFXSOqAKUlnqbj 2019/01/06 2:41 http://onliner.us/story.php?title=switch-cisco-296

Your style is so unique in comparison to other folks I have read stuff from. Many thanks for posting when you ave got the opportunity, Guess I all just book mark this site.

# utssyPYszdipjqXjV 2019/01/07 7:48 https://status.online

please stop by the sites we follow, such as this a single, because it represents our picks in the web

# zwnOlXsZZQvXSjckKa 2019/01/09 19:28 http://braindump.dk/tech/gwt-xdoclet/

You are not probably to achieve virtually just about everywhere if you definitely really don at brush for that

# vFPxYaAKaCNXuYYXZ 2019/01/10 5:36 https://www.abtechblog.com/

I was suggested this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my problem. You are incredible! Thanks!

# mOxFkQNddsnYRpDVfcJ 2019/01/10 22:26 http://thanh1555tn.realscienceblogs.com/we-also-ca

Wow! This can be one particular of the most beneficial blogs We ave ever arrive across on this subject. Basically Great. I am also an expert in this topic therefore I can understand your hard work.

# Informative article, exacgly what I wanted to find. 2019/01/10 22:40 Informative article, exactly what I wanted to find

Informative article, exactly what I wanted to find.

# XBPnRjQYnvePBiqKtTM 2019/01/11 6:23 http://www.alphaupgrade.com

There as certainly a lot to know about this topic. I really like all the points you ave made.

# WGpMkLJiSnKZPCHOZeq 2019/01/12 4:56 https://www.youmustgethealthy.com/contact

This website truly has all the info I needed concerning this subject and didn at know who to ask.

# Hoe arder u trapt, hoe meer ondersteuning u krijgt. 2019/01/12 11:25 Hоe harder u trapt, һoe meer ondersteuning u krijg

Hoe harder u trapt, ?oe meer ondersteuning u krijgt.

# nRnNvenoGgnLYOV 2019/01/14 21:40 http://228mixdj.com/telecharger-arnold-dacruss-ft-

Really appreciate you sharing this article.Thanks Again. Want more.

# yWqfpuZzMMsglY 2019/01/15 4:07 https://cyber-hub.net/

Supporting the thread.. thanks sure, study is paying off. of course, research is paying off. Love the entry you offered..

# XNPguzJoVaZliJPKhS 2019/01/15 8:12 https://giventake.in/user/profile/309120

Outstanding post, I believe blog owners should larn a lot from this web blog its very user friendly.

# TErautuvMgyonCDRZ 2019/01/15 10:08 http://www.colourlovers.com/lover/barcelonaclubs

This excellent website certainly has all of the information I needed about this subject and didn at know who to ask.

# HuUghOjGnIIKVb 2019/01/15 12:07 http://www.100date.com/tips-on-choosing-the-best-s

You forgot iBank. Syncs seamlessly to the Mac version. LONGTIME Microsoft Money user haven\\\ at looked back.

# rgmhRJRqNfroUybJKct 2019/01/15 14:12 https://www.roupasparalojadedez.com

That is a really good tip particularly to those fresh to the blogosphere. Brief but very precise information Thanks for sharing this one. A must read post!

# HIEkNZRNijWozPkppCY 2019/01/16 18:49 http://www.zahidkhan.com/__media__/js/netsoltradem

I think this is a real great post.Really looking forward to read more. Fantastic.

# eTXzXiVizwfgafv 2019/01/16 22:55 http://www.brendanbreathnach.com/__media__/js/nets

I?ve read some just right stuff here. Definitely value bookmarking for revisiting. I surprise how so much attempt you place to make any such great informative website.

# rPCfZZQieJq 2019/01/17 4:54 http://dallashomeandgardenshow.com/__media__/js/ne

Looking forward to reading more. Great blog post. Much obliged.

# It’s appropriate time to make some plans for the future and it is time to be happy. I have read this publish and if I may I want to counsel you some fascinating things or tips. Perhaps you could write subsequent articles regarding this article. I wish t 2019/01/17 7:15 It’s appropriate time to make some plans for the

It’s appropriate time to make some plans for the future and it is time to be happy.

I have read this publish and if I may I want to counsel you some fascinating things or tips.

Perhaps you could write subsequent articles regarding this article.

I wish to learn even more issues approximately
it! Woah! I'm really enjoying the template/theme of this website.

It's simple, yet effective. A lot of times it's very difficult to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a very good job with this.
In addition, the blog loads extremely quick for me on Safari.
Outstanding Blog! Ahaa, its fastidious conversation concerning this post at this place at this web site,
I have read all that, so now me also commenting here. http://www.cspan.net

# It’s appropriate time to make some plans for the future and it is time to be happy. I have read this publish and if I may I want to counsel you some fascinating things or tips. Perhaps you could write subsequent articles regarding this article. I wish t 2019/01/17 7:15 It’s appropriate time to make some plans for the

It’s appropriate time to make some plans for the future and it is time to be happy.

I have read this publish and if I may I want to counsel you some fascinating things or tips.

Perhaps you could write subsequent articles regarding this article.

I wish to learn even more issues approximately
it! Woah! I'm really enjoying the template/theme of this website.

It's simple, yet effective. A lot of times it's very difficult to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a very good job with this.
In addition, the blog loads extremely quick for me on Safari.
Outstanding Blog! Ahaa, its fastidious conversation concerning this post at this place at this web site,
I have read all that, so now me also commenting here. http://www.cspan.net

# It’s appropriate time to make some plans for the future and it is time to be happy. I have read this publish and if I may I want to counsel you some fascinating things or tips. Perhaps you could write subsequent articles regarding this article. I wish t 2019/01/17 7:15 It’s appropriate time to make some plans for the

It’s appropriate time to make some plans for the future and it is time to be happy.

I have read this publish and if I may I want to counsel you some fascinating things or tips.

Perhaps you could write subsequent articles regarding this article.

I wish to learn even more issues approximately
it! Woah! I'm really enjoying the template/theme of this website.

It's simple, yet effective. A lot of times it's very difficult to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a very good job with this.
In addition, the blog loads extremely quick for me on Safari.
Outstanding Blog! Ahaa, its fastidious conversation concerning this post at this place at this web site,
I have read all that, so now me also commenting here. http://www.cspan.net

# It’s appropriate time to make some plans for the future and it is time to be happy. I have read this publish and if I may I want to counsel you some fascinating things or tips. Perhaps you could write subsequent articles regarding this article. I wish t 2019/01/17 7:15 It’s appropriate time to make some plans for the

It’s appropriate time to make some plans for the future and it is time to be happy.

I have read this publish and if I may I want to counsel you some fascinating things or tips.

Perhaps you could write subsequent articles regarding this article.

I wish to learn even more issues approximately
it! Woah! I'm really enjoying the template/theme of this website.

It's simple, yet effective. A lot of times it's very difficult to
get that "perfect balance" between user friendliness and visual appearance.
I must say that you've done a very good job with this.
In addition, the blog loads extremely quick for me on Safari.
Outstanding Blog! Ahaa, its fastidious conversation concerning this post at this place at this web site,
I have read all that, so now me also commenting here. http://www.cspan.net

# tIZKhLklJgVgf 2019/01/17 9:19 http://all4webs.com/studywine4/tuuhgzdtho882.htm

Wow! This blog looks just like my old one! It as on a completely different subject but it has pretty much the same page layout and design. Great choice of colors!

# kIlKsobyWlnldz 2019/01/19 12:27 http://mercore.ru/bitrix/rk.php?goto=http://myspac

Would love to always get updated great web site!.

タイトル  
名前  
Url
コメント