Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7725903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:04:15+00:00 2026-06-01T05:04:15+00:00

I have binary data in my database that I’ll have to convert to bitmap

  • 0

I have binary data in my database that I’ll have to convert to bitmap at some point. I was thinking whether or not it’s appropriate to use a repository and do it there. My consumer, which is a presentation layer, will use this repository. For example:

// This is a class I created for modeling the item as is.
public class RealItem
{
    public string Name { get; set; }
    public Bitmap Image { get; set; }
}

public abstract class BaseRepository
{
    //using Unity (http://unity.codeplex.com) to inject the dependancy of entity context.
    [Dependency]
    public Context { get; set; }
}

public calss ItemRepository : BaseRepository
{
    public List<Items> Select()
    {
        IEnumerable<Items> items = from item in Context.Items select item;
        List<RealItem> lst = new List<RealItem>();
        foreach(itm in items)
        {
            MemoryStream stream = new MemoryStream(itm.Image);
            Bitmap image = (Bitmap)Image.FromStream(stream);
            RealItem ritem = new RealItem{ Name=item.Name, Image=image };
            lst.Add(ritem);
        }

        return lst;
    }
}

Is this a correct way to use the repository pattern? I’m learning this pattern and I’ve seen a lot of examples online that are using a repository but when I looked at their source code… for example:

public IQueryable<object> Select
{
    return from q in base.Context.MyItems select q;
}

as you can see almost no behavior is added to the system by their approach except for hidding the data access query, so I was confused that maybe repository is something else and I got it all wrong. At the end there should be extra benifits of using them right?

Update: as it turned out you don’t need repositories if there is nothing more to be done on data before sending them out, but wait! no abstraction on LINQ query? that way client has to provide the query statements for us which can be a little unsafe and hard to validate, so maybe the repository is also providing an abstraction on data queries? if this is true then having a repository is always an essential need in project architecture!! however this abstraction can be provided by using SQL stored procedures. what is the choice if both options are available?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T05:04:16+00:00Added an answer on June 1, 2026 at 5:04 am

    Yes, that’s the correct way: the repository contract serves the application needs, dealing ony with application objects.

    The (bad)example you are seeing most of the time couples any repository implementation to IQueryable which may or may be not implemented by the underlying orm and after all it is an implementation detail.

    The difference between IQueryable and IEnumerable is important when dealing with remote data, but that’s what the repository does in the first place: it hides the fact you’re dealing with a storage which can be remote. For the app, the repository is just a local collection of objects.

    Update
    The repository abstracts the persistence access, it makes the application decoupled from a particular persistence implementation and masks itself as a simple collection. This means the app doesn’t know about Linq2Sql, Sql or the type of RDBMS used, if any. The app sends/receives objects from the repo, while the repo actually persists or loads objects. The app doesn’t care how the repo does it.

    I consider the repository a very useful pattern and I’m using it in every project, precisely because it marks the boundry between the application (as the place where problems and solutions are defined and handled) and storage/persistence where data is saved.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database which contains picture data stored as a binary blob. The
I have binary data in a file that I can read into a byte
I have a block of binary data defined as: void* address, size_t binarySize; that
I have a simulation that reads large binary data files that we create (10s
I have two files (f1 and f2) containing some text (or binary data). How
I have an external device that spits out UDP packets of binary data and
I've got some binary data that I store and was going to separate this
I have a database that is uft8_general_ci, only problem is up until this point
I have a binary field in my database that is hard to describe in
I have data database containing some rather large strings, each of which holds a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.