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 8399343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:16:42+00:00 2026-06-09T21:16:42+00:00

I have a legacy SQL database that has a linked table to store specifications

  • 0

I have a legacy SQL database that has a linked table to store specifications for order lines. The application designers use an image field in SQL to store the text as binary data. I mocked up an example below:

public class OrderLine
{
    public int ID { get; set; }
    public int OrderID { get; set; }
    public int LineNo { get; set; }
    public string Product { get; set; }
    public decimal Quantity { get; set; }
    public decimal UnitPrice { get; set; }
    public string Status { get; set; }
}

public class OrderLineSpecifications
{
    public int ID { get; set; }
    public int OrderID { get; set; }
    public int OrderLineNo { get; set; }
    public Image Bits { get; set; }   // <--- This Line
    public int Bit_Length { get; set; }
}

SQL Table Definition

    [ID] [int] IDENTITY(1,1) NOT NULL,
    [OrderID] [varchar](15) NOT NULL,
    [OrderLineNo] [smallint] NOT NULL,
    [Bits] [image] NULL,
    [Bit_Length] [int] NOT NULL

Currently I have to use SQL with

cast(cast(Bits as varbinary(max)) as varchar(max)) 

to extract the text and then perform the reverse to return it to the database. Is it possible to have the conversion done in EF? Perhaps at the property level { get; set;} ?

  • 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-09T21:16:43+00:00Added an answer on June 9, 2026 at 9:16 pm

    The solution was easier than I thought. I changed what was identified as an Image in SQL to a byte array (byte[]) and created a property (Specs) that processed the BITS values. Entity Framework was happy and it works in both directions. Surprisingly easy.

    public virtual byte[] BITS { get; set; }
    public virtual int BITS_LENGTH { get; set; }
    [NotMapped]
    public virtual string Specs
    {
        get
        {
            UTF8Encoding enc = new UTF8Encoding();
            string str = enc.GetString(BITS);
            return str;
        }
        set
        {
            UTF8Encoding encoding = new UTF8Encoding();
            BITS = encoding.GetBytes(value);
         }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a legacy SQL Server 2000 database that has one column that has
I have a legacy data table in SQL Server 2005 that has a PK
I have a table in a legacy database that has a column named field.
In a legacy database (SQL Server 2000), we have a clustered index that looks
I have a legacy application that uses the ASP.NET membership provider w/ SQL backend.
I currently have a legacy database (SQL 2005) that generates hash strings for tokens.
I am using playframework with a legacy SQL Server 2008 database that has data
I have a 'legacy' DB2 database that has many other applications and users. Trying
I'm working with a legacy SQL Server database which has a core table with
I have a legacy mysql database and there's this table which has a few

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.