Click here to Skip to main content
15,890,557 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: About Graphics Pin
Luc Pattyn18-Aug-09 2:19
sitebuilderLuc Pattyn18-Aug-09 2:19 
Questioncrystall reports in visual studio 2008 Pin
220817-Aug-09 18:40
220817-Aug-09 18:40 
QuestionCrystal Report Report Tille Pin
chushia17-Aug-09 10:54
chushia17-Aug-09 10:54 
Questionhow to create file downloding method in ASP.NET Pin
simran123456 217-Aug-09 2:00
simran123456 217-Aug-09 2:00 
AnswerRe: how to create file downloding method in ASP.NET Pin
Adam R Harris17-Aug-09 11:36
Adam R Harris17-Aug-09 11:36 
QuestionIEquality Comparer distinct datatable rows Pin
vidhyaravichandar17-Aug-09 0:58
vidhyaravichandar17-Aug-09 0:58 
AnswerRe: IEquality Comparer distinct datatable rows Pin
Henry Minute17-Aug-09 1:10
Henry Minute17-Aug-09 1:10 
GeneralRe: IEquality Comparer distinct datatable rows Pin
vidhyaravichandar17-Aug-09 1:19
vidhyaravichandar17-Aug-09 1:19 
thanks for ur reply,

here is my code....

my datatable(named as sortedDataTable) has columns as in my previous message... and i use iequalitycomparer as below
IEnumerable<DataRow> drdistinct = sortedDataTable.AsEnumerable().Distinct(new MyDataRowComparer());


in my iequalitycomparer class i have these codes...

<pre>
class MyDataRowComparer : IEqualityComparer<DataRow>
{
public MyDataRowComparer()
{
}

public bool Equals(DataRow x, DataRow y)
{
if (x.Field<string>("Fam.") == y.Field<string>("Fam.") && x.Field<string>("Description") == y.Field<string>("Description"))
{
x["Component"] = Convert.ToInt16(x["Component"]) + 1;
x["Quantity"] = Convert.ToDouble(x["Quantity"]) + Convert.ToDouble(y["Quantity"]);
//y.Delete();
return true;
}
else
return false;
}

public int GetHashCode(DataRow obj)
{
int a = obj.Field<string>("Fam.").GetHashCode();
int b = obj.Field<string>("Description").GetHashCode();

// obj["Component"] = Convert.ToInt16(obj["Component"]) + 1;
//x["Quantity"] = Convert.ToDouble(x["Quantity"]) + Convert.ToDouble(y["Quantity"]);
return a + b;
} </pre>

these code, works fine and it returns me only the distinct rows, but this gethashcode method adds the first row and then compares it with subsequent rows, so if i apend column values in equals method as in above, it doesnt affect the datatable as it adds the row in the begining itself..
GeneralRe: IEquality Comparer distinct datatable rows Pin
Henry Minute17-Aug-09 1:52
Henry Minute17-Aug-09 1:52 
GeneralRe: IEquality Comparer distinct datatable rows Pin
vidhyaravichandar17-Aug-09 15:21
vidhyaravichandar17-Aug-09 15:21 
GeneralRe: IEquality Comparer distinct datatable rows Pin
Henry Minute18-Aug-09 0:22
Henry Minute18-Aug-09 0:22 
QuestionDot Net Installer Pin
Ageesh17-Aug-09 0:44
Ageesh17-Aug-09 0:44 
AnswerRe: Dot Net Installer Pin
Adam R Harris17-Aug-09 11:44
Adam R Harris17-Aug-09 11:44 
QuestionImporting Dll Problem Pin
shaina223116-Aug-09 17:42
shaina223116-Aug-09 17:42 
AnswerRe: Importing Dll Problem Pin
Adam Maras16-Aug-09 18:09
Adam Maras16-Aug-09 18:09 
AnswerRe: Importing Dll Problem Pin
Pete O'Hanlon16-Aug-09 22:48
mvePete O'Hanlon16-Aug-09 22:48 
AnswerRe: Importing Dll Problem Pin
Luc Pattyn17-Aug-09 0:16
sitebuilderLuc Pattyn17-Aug-09 0:16 
GeneralRe: Importing Dll Problem Pin
Adam Maras17-Aug-09 10:12
Adam Maras17-Aug-09 10:12 
QuestionClass Problem Pin
JEFFERY!16-Aug-09 13:27
JEFFERY!16-Aug-09 13:27 
AnswerRe: Class Problem Pin
Luc Pattyn16-Aug-09 14:52
sitebuilderLuc Pattyn16-Aug-09 14:52 
GeneralRe: Class Problem Pin
JEFFERY!16-Aug-09 15:01
JEFFERY!16-Aug-09 15:01 
GeneralRe: Class Problem Pin
Luc Pattyn16-Aug-09 15:02
sitebuilderLuc Pattyn16-Aug-09 15:02 
QuestionUnwanted and junk file cleaner Pin
agyzone@gmail.com16-Aug-09 5:26
agyzone@gmail.com16-Aug-09 5:26 
AnswerRe: Unwanted and junk file cleaner Pin
Not Active16-Aug-09 5:33
mentorNot Active16-Aug-09 5:33 
AnswerRe: Unwanted and junk file cleaner Pin
Luc Pattyn16-Aug-09 9:08
sitebuilderLuc Pattyn16-Aug-09 9:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.