Hi,
My apologies if this has been asked before, I can't find it if it has.
I am retrieving some products using a SPROC in an Sql 2005 db. I'm then projecting them on to a ProductCollection. This is all working fine but the problem I'm having is that the state of the entities in the product collection (ProductCollection[0].Fields.State) is set to EntityState.New which is causing issue further down the line. I understand that when using projection, only the field properties are propulated so Fields.State never get set to EntityState.Fetched but how can I change this? Here's the code I'm currently using:
ProductCollection products = new ProductCollection(new ExtendedProductFactory());
using (IRetrievalQuery query = RetrievalProcedures.GetSearchProductFuzzyCallAsQuery(keyword, applicationId))
{
TypedListDAO dao = new TypedListDAO();
using (IDataReader reader = dao.GetAsDataReader(null, query, CommandBehavior.CloseConnection))
{
List<IDataValueProjector> valueProjectors = new List<IDataValueProjector>();
valueProjectors.Add(new DataValueProjector(ProductFieldIndex.Id.ToString(), 2, typeof(int)));
valueProjectors.Add(new DataValueProjector(ProductFieldIndex.Code.ToString(), 3, typeof(string)));
valueProjectors.Add(new DataValueProjector(ProductFieldIndex.Name.ToString(), 4, typeof(string)));
.....
DataProjectorToIEntityCollection projector = new DataProjectorToIEntityCollection(products);
dao.GetAsProjection(valueProjectors, projector, reader);
reader.Close();
}
}
return products;
Thanks in advance for any help.
Chris.