3
Func<FooEntity, double> selector = null;
selector = x => x.M1_TotalLoss;

var entity = FooEntity
    .Where(x => x.Year == year)
    .GroupBy(gp => gp.Year)
    .Select(ss => new FooDto
    {
        SumTotalLoss = ss.Sum(selector)
    })
    .FirstOrDefaultAsync();

I need sum dynamic selector.

Error = Internal .NET Framework Data Provider error 1025.

anıl yıldırım
  • 953
  • 1
  • 10
  • 17
  • 1
    Is that error all the exception details? – Camilo Terevinto Oct 22 '17 at 13:57
  • have you seen this https://stackoverflow.com/questions/11990158/internal-net-framework-data-provider-error-1025 ? – derloopkat Oct 22 '17 at 13:59
  • @CamiloTerevinto thanks your reply, "exceptionMessage=Internal .NET Framework Data Provider error 1025." only message – anıl yıldırım Oct 22 '17 at 13:59
  • can you show 'FooEntity'? – Maor Veitsman Oct 22 '17 at 14:10
  • @derloopkat yes, it's not solution. – anıl yıldırım Oct 22 '17 at 14:10
  • @anılyıldırım, when you get the error is there an inner exception ? – derloopkat Oct 22 '17 at 14:13
  • @derloopkat added picture. – anıl yıldırım Oct 22 '17 at 14:20
  • 1
    Try to replace the definition of `selector` from `Func` to `Expression>` – haim770 Oct 22 '17 at 14:34
  • @haim770 select is need Func, i use expression error , does not contain a definition – anıl yıldırım Oct 22 '17 at 14:36
  • `ss.AsQueryable().Sum(selector)` will do. But I suspect it will fail at runtime – haim770 Oct 22 '17 at 14:42
  • Thanks @haim770 it's work. You save my day :) – anıl yıldırım Oct 22 '17 at 14:49
  • Please add code, errors and data as **text** ([using code formatting](//stackoverflow.com/editing-help#code)), not images. Images: A) don't allow us to copy-&-paste the code/errors/data for testing; B) don't permit searching based on the code/error/data contents; and [many more reasons](https://meta.stackoverflow.com/a/285557). In general, code/errors/data in text format >>>> code/errors/data as an image >> nothing. Images should only be used, *in addition to text in code format*, if having the image adds something significant that is not conveyed by just the text code/error/data. – Makyen Oct 22 '17 at 23:09
  • @Makyen :) it's funny. Before writing a comment , you read question. I wrote my error. It's font is bold. It is not my problem that the error is short and look at the comments They are heard the need to put a picture for you. They understood and answered the error. – anıl yıldırım Oct 23 '17 at 07:06
  • @anılyıldırım I did read the question, and looked at the screenshot which you had included in the question at that time. The error information is considerably more that what you included as text. The entire contents of the JSON (even more than is displayed in your screenshot, e.g. the `stackTrace`) is relevant information about the error. It should be included in the question. – Makyen Oct 23 '17 at 08:22
  • @Makyen thank you for information. I will be more careful. – anıl yıldırım Oct 23 '17 at 08:56

1 Answers1

0
ss.AsQueryable().Sum(selector)
anıl yıldırım
  • 953
  • 1
  • 10
  • 17