Help on EasyEntity

Data Access Application Blocks Forum

Help on EasyEntity

Postby weidong on Sun Nov 30, 2008 9:13 am

Hi,
I am new to this tool and I got the following problem with I was using this framework,
REG regs = new REG();
ArrayList ListReg = new ArrayList();
regs.Where.F_ROTA_ID.Value = 1;
regs.Query.Load();
if (regs.RowCount > 0)
{
regs.Rewind();
do
{
ListReg.Add(regs);
} while (regs.MoveNext());
}
if (ListReg.Count>0)
{
string msg = "";
for (int i = 0; i < ListReg.Count; i++)
{
REG reg = (REG)ListReg[i];
msg = String.Format("[REG {0}]", reg.F_TYPE_ID.ToString());
Console.WriteLine(msg);
}
}

In my testing database regs.Query.Load() will return three objects, whose F_TYPE_ID are 1,2,3 respectively. However, the output is [REG 3], [REG 3], [REG 3]. Obviously they all point to the last row. I have read the documentation and did not find a method that I can keep the three objects in three seperate variables at the same time. Could you help me?

Many thanks.
weidong
Lurker
 
Posts: 1
Joined: Sun Nov 30, 2008 9:05 am

Re: Help on EasyEntity

Postby mgnoonan on Wed Dec 03, 2008 12:50 am

It seems to me you are over-complicating things a bit. This should work for you:

Code: Select all
REG regs = new REG();
regs.Where.F_ROTA_ID.Value = 1;

if (regs.Query.Load())
{
   do
   {
      string msg = String.Format("[REG {0}]", reg.s_F_TYPE_ID);
      Console.WriteLine(msg);
   } while (reg.MoveNext());
}
Matt Noonan
EasyObjects.NET - The O/RM for the Enterprise Library
http://www.easyobjects.net
User avatar
mgnoonan
Expert
 
Posts: 1019
Joined: Tue Sep 14, 2004 3:17 am
Location: Springboro, OH


Return to EasyObjects.NET (Microsoft Enterprise Library)

Who is online

Users browsing this forum: No registered users and 1 guest

cron