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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:25:13+00:00 2026-05-11T15:25:13+00:00

Given this table: CREATE TABLE [Comments] ( [Id] [int] IDENTITY(1, 1) NOT NULL, [Text]

  • 0

Given this table:

CREATE TABLE [Comments] (   [Id] [int] IDENTITY(1, 1) NOT NULL,    [Text] [nvarchar](600) NOT NULL ) 

With this model class:

[Table(Name='Comments')] public class Comment {     [Column(AutoSync = AutoSync.OnInsert, DbType = 'Int NOT NULL IDENTITY', IsPrimaryKey = true, IsDbGenerated = true)]     public int Id { get; set; }      [Column(DbType = 'NVarChar(600) NOT NULL', CanBeNull = false)]     public string Text { get; set; }      public string ArbitraryText { get; set; } } 

Is it possible for a DataContext to fill the ArbitraryText property when using the ExecuteQuery method:

var comments = db.ExecuteQuery<Comment>('select Id, [Text], 'hello' [ArbitraryText] from Comments'); 

It seems that the entity mapping algorithm ignores any property not marked with ColumnAttribute, but is there another way of doing this?

I’d prefer not having to do the mapping myself, but this looks like my only option.


Edit: What’s annoying is that the DataContext.ExecuteQuery function will fill a POCO object from a query:

public class PlainOldCSharpObject {     public int Id { get; set; }     public string Text { get; set; }     public string ArbitraryText { get; set; } } ... // DataContext correctly fills these objects var pocos = db.ExecuteQuery<PlainOldCSharpObject>('select Id, [Text]... 

So my current solution is to have an inner class on my LINQ-mapped object that holds the extra data my aggregate query returns. This is sub-optimal, as some properties are duplicated (for example, Id and Text).

  • 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. 2026-05-11T15:25:13+00:00Added an answer on May 11, 2026 at 3:25 pm

    Not as far as I know. You could probably do some grungy things to marry data from a UDF, perhaps – but other than that, it is going to want to be able to map the columns.

    (where the UDF just returns the arbitrary text and the comment-id)

    var qry = from row in db.SomeUdfQuery(someArgs)           join comment in db.Comments           on row.Id equals comment.Id           select new {Comment = comment, row.ArbitraryText};  var comments = new List<Comment>(); foreach(var record in qry) {     record.Comment.ArbitraryText = record.ArbitraryText;     comments.Add(record.Comment); } return comments; 

    Alternatively – A while I wrote a few variants on ExecuteQuery that might be useful if you need to use this approach for lots of different things… Personally, I’d probably try to side-step the issue first, though.

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

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It depends. Could be premature optimization. With smaller columns, you… May 11, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer For what you are trying to accomplish you might want… May 11, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer First off, make sure the WebService is set to Dynamic.… May 11, 2026 at 11:49 pm

Related Questions

(NOTE: This question is not about escaping queries, it's about escaping results) I'm using
I'm terribly new to SQL, and cannot seem to get the desired information out,
We develop and operate a blogging application in which user data a scattered across
I get the message literal does not match format string. For instance, here are

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.