I want to get a specific occurrance of a collection with all the items in that collection, for instance, getting all the values in the first occurrence of lets's say 3 occurrences.
How would I accomplish this if I have the below code? If i is equal to 1, I just want the first occurrence out of the collection to pass to my ProcessForm4PDFFormFields method with just this one occurrence instead of the entire collection.
So, the parameter "myResult" would only contain just one of the occurrences to pass based on what "i" is.
public void GetForm4Results(string FormId, int LoanId, string MainDir3, string TemplateFile, Int16 i)
{
try
{
using (VisionEntities DbContext = new VisionEntities())
{
DbContext.Configuration.LazyLoadingEnabled = false;
DbContext.Database.Connection.Open();
int? LoanIdTmp = LoanId;
ObjectResult<SelectForm4_Result> result = DbContext.SelectForm4(8900, LoanId);
List<SelectForm4_Result> myResult = new List<SelectForm4_Result>();
myResult = result.ToList();
ProcessForm4PDFFormFields(myResult, FormId, MainDir3, TemplateFile, i);
}
}
catch (Exception ex)
{
throw ex;
}
}
So you're saying you want myResult to contain the first i
objects in result?
myResult = result.Take(i).ToList();
Or if you want myResult to contain only the i
th object in result, it would be...
myResult = new List<SelectForm4_Result>() { result.ElementAt(i) };
Source: http://msdn.microsoft.com/en-us/library/bb739113.aspx