|
while (rdr.Read())
{
emp.ID = rdr["ID"].ToString();
emp.Name = rdr["Name"].ToString();
emp.Gender = rdr["Gender"].ToString();
emp.Email = rdr["Email"].ToString();
emp.Roles = rdr["Roles"].ToString();
}
hear I am passing rdr["ID"].ToString().....
line by line
i want this to be executed in a single line
is it posible
Thanks Gopi Krishna
|
|
|
|
|
If you have a constructor which accepts the property values, then your commented-out line will work.
If you don't, an object initializer might help:
emp = new EmployeeBLL
{
ID = Convert.ToString(rdr["ID"]),
Name = Convert.ToString(rdr["Name"]),
Gender = Convert.ToString(rdr["Gender"]),
Email = Convert.ToString(rdr["Email"]),
Roles = Convert.ToString(rdr["Roles"]),
};
You might also want to look at Dapper[^]:
using (var connection = new SqlConnection("..."))
{
List<EmployeeBLL> employees = connection.Query<EmployeeBLL>(
"SELECT ID, Name, Gender, Email, Roles FROM YourTable WHERE SomeCondition = @SomeParameter",
new { SomeParameter = "some value" })
.ToList();
...
}
Or AutoMapper[^] with the AutoMapper.Data[^] extension:
using (var connection = new SqlConnection("..."))
using (var command = new SqlCommand("SELECT ID, Name, Gender, Email, Roles FROM YourTable WHERE SomeCondition = @SomeParameter", connection))
{
command.Parameters.AddWithValue("@SomeParameter", "some value");
connection.Open();
using (var reader = command.ExecuteReader(CommandBehavior.CloseConnection))
{
if (reader.HasRows)
{
List<EmployeeBLL> employees = Mapper.DynamicMap<IDataReader, List<EmployeeBLL>>(reader);
...
}
}
}
(Code based on this StackOverflow answer[^].)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Can I write a code at home in code project to see it later in office
can i use this site for that help
|
|
|
|
|
You can ask for help here at CodeProject. But you should use the appropiate forum[^] or Quick Answers[^] and be specific. Your actual question is rather unclear.
Your later posts shown above are just code dumps. Nobody here will have a look at them. So please delete these post.
|
|
|
|
|
No.
That is not what this site is about.
Instead, look at setting up a DropBox account - it 's free and it exists for just that kind of thing.
https://www.dropbox.com/[^]
Your existing messages are getting abuse votes, so I will delete them.
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
|
hi, i'd like to make an sd card with multiple partitions to be able to be seen from windows. but as you know, windows can only see the first partition on removable disks and that sucks. is there a way on a 64bits windows to see more than the first partition on a removable disk or to make it as a fixed disk ?
|
|
|
|
|
|
14:43:38 [Apache] Status change detected: stopped
14:43:38 [Apache] Error: Apache shutdown unexpectedly.
14:43:38 [Apache] This may be due to a blocked port, missing dependencies,
14:43:38 [Apache] improper privileges, a crash, or a shutdown by another method.
14:43:38 [Apache] Press the Logs button to view error logs and check
14:43:38 [Apache] the Windows Event Viewer for more clues
14:43:38 [Apache] If you need more help, copy and post this
14:43:38 [Apache] entire log window on the forums
|
|
|
|
|
By following the advices giving in the log:
Quote: Press the Logs button to view error logs and check the Windows Event Viewer for more clues
This refers more to an Apache specific forum but still requires the log messages:
Member 12158426 wrote: If you need more help, copy and post this entire log window on the forums
|
|
|
|
|
Hi All, I am trying to accrue some data about how/when/why we document. I have a survey on surveymonkey. If you code could you please take two minutes and complete this survey?? Thank you...
https://www.surveymonkey.com/r/WXLKYNG
|
|
|
|
|
|
Thank you! The more data... the better results!
|
|
|
|
|
i'm new to this forum, i don't know where to ask this question.
i wanna ask, what's the IDE and compiler for assembly in windows (10)? can somebody give me the links? coz i've tried google it up but the results is a lil bit vague...
|
|
|
|
|
Apparently, this know bug was never fixed as promised.
|
|
|
|
|
Exactly what are you talking about and what do you want? Please explain your problem clearly in a single question rather than posting these cryptic complaints.
|
|
|
|
|
Out of the box, I tried to save an encrypted text as the default "safe" extension. I received the unhandled exception error. I tried to find what I was doing wrong and finally figured out that it was the "sate" extension and saved it as a txt file. It worked. I was confused by the fact that the default extension was set to something that would not work.
I was really unhappy about the discussion forum. The help referred me to the correct forum and I found the reference to the unhandled exception. I then tried to post on my problem and could not find any way to do that. The only way I could post was in the Ask a question. It was very frustrating and annoying, but now it works well enough to use.
|
|
|
|
|
Still have no idea what you are talking about, or why you decided to post your complaints on this forum.
|
|
|
|
|
As mentioned before, this is not the right place. Contact the vendor.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Cannot get cryptpad to work. Unhandled exception. Something about index. Several tries and reading instructions and all I know is that this program is a waste of time.
|
|
|
|
|
Ron Christensen wrote: this program is a waste of time. So what do you expect people here to do about it?
|
|
|
|
|
Please report this to the vendor who made the product.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
how do i post a question?
|
|
|
|
|
|
Better to post in the appropriate forum by clicking the links to the left.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I will make a datasheet, where i first load up a excel sheet, for example with a number and a weight. Now I will get two placeholders one for the number and one for the weigth. Then I only will change the number and then the weight has to change at his own. It also must be updateable with a new excelsheet.
May you can help me?
Please only ask if you have knowlege in Indesign...
|
|
|
|