I have table that has multiple data for the same Id. I need to combinations on this data.
For example this the table contain
ID Visit DAte Visit number Rational
-----------------------------------------------
1 14/05/2011 1 new
1 15/06/2012 2 Emergency
1 17/07/2012 3 Check-Up
up to 20 visit
The result that I want is like this
ID Visit DAte Visit number Rational
-------------------------------------------------
1 14/05/2011 1 new
1 15/06/2012 2 Emergency
1 17/07/2012 3 Check-Up
1 14/05/2011 1 new
1 15/06/2012 2 Emergency
1 19/07/2012 4 follwo-up
1 14/05/2011 1 new
1 15/06/2012 2 Emergency
1 18/12/2012 5 Check-Up
etc....
The last one will be
1 14/01/2011 18 Referral
1 15/02/2012 19 Check-up
1 18/10/2012 20 Emergency
Can I do this by query?
//– I define a class and I define a list from that class
public struct ACVsize5
{
public int ID;
public DateTime date;
public int RaId;
public int HpId;
public int DgId;
public int VisitNum;
}
List<ACVsize5> patient = new List<ACVsize5>();
I used this quer but this select two value but i need to get 3 or more
var query = patient.SelectMany((value, index) => patient.Skip(index + 1),
(first,second) => new { first, second });
//– edit
I have to check the combination for one patient to match it with other 4 patients
I came up with generate the first combination if it is match i continue to generate the rest but this operation took long time process how i can increase the performance for the code below ?
for (int j = 0; j < 10000; j++)
{
int id1 = getid(names[j].ToString(), 10000);
for (int t = 0; t < 10000; t++)
{
generate_firstACV5A(id1, nvisit(id1), names[j].ToString());
int id2 = getid(names[t].ToString(), 10000);
if (id1 == id2) { }
else
{
generate_firstACV5B(id2, nvisit(id2), names[t].ToString());
if (comparefirst()==true)
{
if (count == 0)
{
safecount++;
if (safecount == 4) break;
}
Here’s some example code that will generate sets of 3. I don’t know how an ORM will handle this if you let it handle the querying but if you have it locally as objects.
Using your code: