c# 将mysql当前结果与行中的下一个结果进行比较
为了迭代我的结果集(列表列表),我当前正在使用:
foreach (IELog ieLog in emailAttach)
{
logAttachment += ieLog.FirstName + "," + ieLog.LastName +
"," + ieLog.Building + "," + ieLog.Room + "," + ieLog.Ingresstime + ","
+ ieLog.Egresstime + "\n";
}
我想将 ieLog.FirstName 与行中的下一个和图像进行比较,它会像这样工作,只是我的语法是错误的。
n = 0;
while (emailAttach.FirstName [n] == emailAttach.FirstName[n++] {
do something;
}
结果集如下所示:
Person |登录 |注销
约克亨特超时 约克亨特超时
约克亨特超时
约克亨特
超时
迈克亨特超时
迈克亨特
超时 迈克亨特
超时 迈克亨特超时
我的目标只是一次的名字
约克亨特超时
intime outtime
intime outtime
intime outtime
迈克亨特超时超时
intime outtime
intime outtime
intime outtime
谢谢您的帮助!
To iterate through my result set, a lists of lists, I'm currently using:
foreach (IELog ieLog in emailAttach)
{
logAttachment += ieLog.FirstName + "," + ieLog.LastName +
"," + ieLog.Building + "," + ieLog.Room + "," + ieLog.Ingresstime + ","
+ ieLog.Egresstime + "\n";
}
I would like to compare ieLog.FirstName with the next one in line and image it would work something like this, just my syntax is wrong.
n = 0;
while (emailAttach.FirstName [n] == emailAttach.FirstName[n++] {
do something;
}
The result set looks like:
Person | Login | Logout
York Hunt intime outtime
York Hunt intime outtime
York Hunt intime outtime
York Hunt intime outtime
Mike Hunt intime outtime
Mike Hunt intime outtime
Mike Hunt intime outtime
Mike Hunt intime outtime
and I'm aiming for just the name once
York Hunt intime outtime
intime outtime
intime outtime
intime outtime
Mike Hunt intime outtime
intime outtime
intime outtime
intime outtime
Thank you for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
假设您可以使用 LINQ(至少在客户端),您应该只使用
source.GroupBy(x => x.FirstName)
将相同名称的条目分组在一起。Assuming you have LINQ available to you (at least at the client) you should just use
source.GroupBy(x => x.FirstName)
to group entries for the same name together.您可以在 MySQL 中执行此操作。
http://www .mysqlfaqs.net/mysql-faqs/SQL-Statements/Select-Statement/DISTINCT-在 MySQL 中工作
You could do this in MySQL instead.
http://www.mysqlfaqs.net/mysql-faqs/SQL-Statements/Select-Statement/How-does-DISTINCT-work-in-MySQL
您正在尝试获取
emailAttach
内第 n 项的FirstName
属性。换句话说,
emailAttach[n].FirstName
。另外,您需要将
n++
更改为++n
。You're trying to get the
FirstName
property of the nth item insideemailAttach
.In other words,
emailAttach[n].FirstName
.Also, you need to change
n++
to++n
.