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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:28:05+00:00 2026-06-08T11:28:05+00:00

dynamic traceFile = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + \\EntityFrameworkTrace.log; var CurrentStock = (from s in DBViews.StockStatus where

  • 0
dynamic traceFile =  Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\EntityFrameworkTrace.log";                
var CurrentStock = (from s in DBViews.StockStatus
                    where s.ProductID != 10
                    orderby s.ProductName
                    select new
                    {
                        s.ProductID,
                        s.ProductName,
                        CurrentStock = s.TotalStocked - s.TotalSold,
                        s.CurrentSellingRate,
                        CashValue = (s.TotalStocked - s.TotalSold) * s.CurrentSellingRate,
                        s.LastStocked,
                        s.LastCostPrice,
                        s.LastQtyStocked
                    }).ToList();

File.AppendAllText(traceFile, CurrentStock.toTraceString());   
return CurrentStock.ToList();

How can get toTraceString() from CurrentStock on in the following line? it ain’t being resolved

File.AppendAllText(traceFile,  CurrentStock.toTraceString()); 
  • 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-08T11:28:08+00:00Added an answer on June 8, 2026 at 11:28 am

    You cannot because you have already called ToList – it is not a Linq-to-Entities query but simply a List instance.

    Try this:

    var CurrentStock = (from s in DBViews.StockStatus
                        where s.ProductID != 10
                        orderby s.ProductName
                        select new
                        {
                            s.ProductID,
                            s.ProductName,
                            CurrentStock = s.TotalStocked - s.TotalSold,
                            s.CurrentSellingRate,
                            CashValue = (s.TotalStocked - s.TotalSold) * s.CurrentSellingRate,
                            s.LastStocked,
                            s.LastCostPrice,
                            s.LastQtyStocked
                        }); // No ToList here!
    
    File.AppendAllText(traceFile, ((ObjectQuery)CurrentStock).ToTraceString());   
    return CurrentStock.ToList();
    

    Btw. why are you using dynamic instead of string? Dynamic type is only for special cases where that makes sense – this is not the case.

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

Sidebar

Related Questions

Dynamic integer will be any number from 0 to 150. i.e. - number returns
The dynamic request looks like this: request := 'select * from ' || param_table_name
(dynamic query...) select * from myTable where ( <--- @param1 IS NULL OR (
I have a dynamic page that pulls the categories from the database. this page
Dynamic languages are on the rise and there are plenty of them: e.g. Ruby,
Dynamic allocations with new/delete are said to take place on the free-store , while
Dynamic Data question: I have 2 fields of type Nullable<DateTime> on my model When
Dynamic Query is a single C# file you add to your project. Anyone know
If dynamic resolves to object at compile time, and all .NET types extend object,
Can Dynamic libraries have global, local and static variables in linux? If yes, then

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.