Print Page | Close Window

Deleting a blob without loading the record.

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2150
Printed Date: 10-Jun-2026 at 8:53pm


Topic: Deleting a blob without loading the record.
Posted By: BringerOD
Subject: Deleting a blob without loading the record.
Date Posted: 11-Sep-2010 at 2:57pm

Is there any way to delete a row in a table without querying it first?

I need to delete a file with a large amount of data with loading it.
 
I saw this code below on EF and it does not seem to work with DevForce.
 
I guess I could attach a stored procedure.
 
 
---------------------------------------------------------------------

var file = new File();

file.FileId = CurrentEntity.FileId.Value;

file.EntityKey = new EntityKey("PrimeEntities.Files", "FileId", CurrentEntity.FileId.Value.ToString());

PrimeEntities.Attach(file);

PrimeEntities.DeleteObject(file);

PrimeEntities.SaveChanges();




Replies:
Posted By: smi-mark
Date Posted: 12-Sep-2010 at 11:19am
I think you can define an entity that doesn't load all the properties.

Say you have a table called File with columns FileId and Data, you can have your entity only load the FileId column, and then you are not loading the blob data.


Posted By: BringerOD
Date Posted: 12-Sep-2010 at 11:26am

How do you only load the FileId column?

 
Bryan


Posted By: smi-mark
Date Posted: 12-Sep-2010 at 11:36am
I'm not sure if there is a better way, but this is one approach:

http://blogs.msdn.com/b/adonet/archive/2008/12/05/table-splitting-mapping-multiple-entity-types-to-the-same-table.aspx

You are essentially splitting your table into two entity types. One with the image, one without. If you don't want the image you simply query the one without the image.


Posted By: BringerOD
Date Posted: 12-Sep-2010 at 11:54am
Thanks!
 
I have done the table splitting before.  I guess I just forgot about it, since I already made a seperate table for the files, I figured I would not have to split the file table.  Seemed redundant.  It is a solution though. 
 
I think I will just use the a stored procedure.
 
Thanks for your help.
 
Bryan



Print Page | Close Window