New Posts New Posts RSS Feed: Getting entity back but skipping some fields
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Getting entity back but skipping some fields

 Post Reply Post Reply
Author
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Topic: Getting entity back but skipping some fields
    Posted: 23-Nov-2011 at 7:00pm
I have some entities which contain binary data. I'd like to query this data but skip that binary field so I can download it later on demand. Is that possible somehow?
 
var query =
                from mi in this.entityManager.SYSMailItems
                    .Include(SYSMailItem.PathFor(x => x.MEMUser))
                    .Include("SYSMailRecipients.MEMUser")
                    .Include(SYSMailItem.PathFor(x => x.SYSMailAttachments))
                orderby mi.MailItemKey descending
                select mi;
 
I'm talking about SYSMailAttachments.
I understand I can brake this query into 2 and make projection into custom/anon object but I really like to get all this info in one shot and then get binary data separately. Any magic I can use within DevForce?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 23-Nov-2011 at 7:51pm
Hmm, the only way I can think of is to separate that binary data field into another entity. So you will have a 1:1 or 0,1:1 relationship with the binary data entity.

This is probably be better as well in the long run as downloading large chunks of binary data can consume large memory.
Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 23-Nov-2011 at 7:57pm
Right. I was also thinking about moving it into separate table in SQL Server.
 
Or do you mean I can separate this into entity with Entity designer?
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 28-Nov-2011 at 12:56pm
You actually need to create a separate table and entity for this. The main entity will have this binary data entity as a navigation entity which, when you do your queries, you can choose to not include this entity, thus reducing your payload.
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 28-Nov-2011 at 2:22pm
Just found out that you don't have to create a separate table for this. You can map a table to multiple entities. This concept is called Table Splitting in EF.


There's also the opposite concept called Entity Splitting where you can map an entity to multiple tables. 



Back to Top
katit View Drop Down
Senior Member
Senior Member


Joined: 09-Sep-2011
Posts: 146
Post Options Post Options   Quote katit Quote  Post ReplyReply Direct Link To This Post Posted: 28-Nov-2011 at 2:26pm
I already split actual table, it will be better in a long run I think. Splitting entity will be problematic if I want to regenerate model from scratch. Right now I can do it easily.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down