ApplyCurrentValues in EF 4

Posted by ali62b on Stack Overflow See other posts from Stack Overflow or by ali62b
Published on 2010-02-16T11:01:54Z Indexed on 2010/04/10 17:53 UTC
Read the original article Hit count: 1267

I just was playing with EF 4 in VS 2010 RC and just found that ApplyCurrentValues dont work when the Property is of type bool and the newly value is false !!!???
and it works when the newly value is true .
I dont know if this is a bug or I'm missing something but I just work with a very ugly work around :

public void UpdateProduct(Product updatedProduct)
    {
        using (model)
        {
            model.Products.Attach(new Product { ProductID = updatedProduct.ProductID });
            model.Products.ApplyCurrentValues(updatedProduct);
            Product originalProduct = model.Products.Single(p => p.ProductID == updatedProduct.ProductID);
            originalProduct.Discontinued = updatedProduct.Discontinued;
            model.SaveChanges();

        }

    }

any idea or better work around?

© Stack Overflow or respective owner

Related posts about entity-framework

Related posts about .NET