Entity Framework - Cannot convert lambda expression to type 'string' because it is not a delegate type

后端 未结 15 2215
再見小時候
再見小時候 2020-11-30 09:18

I am using Entity Framework in my C# based code. I am running into an unexpected weirdness and am looking for suggestions.

Case 1, 2, 3, 4... Projects:
RivWorks

相关标签:
15条回答
  • 2020-11-30 10:03

    For .Net Core just introduce;

    using System.Linq;
    using Microsoft.EntityFrameworkCore;
    
    0 讨论(0)
  • 2020-11-30 10:08
    using System.Linq;
    using System.Data.Entity;
    
    0 讨论(0)
  • 2020-11-30 10:09

    I was struggling with this in a Telerik Grid template within a Razor view for about an hour. In my case, this:

    columns.Bound(x => x.ID).Template(@<text><a href="@(Model.AppUrl + AdditionalFeeTypes/Details/" + item.ID)">@item.ID</a></text>);
    

    was supposed to be this:

    columns.Bound(x => x.Id).Template(@<text><a href="@(Model.AppUrl + AdditionalFeeTypes/Details/" + item.Id)">@item.Id</a></text>);
    

    The case on "Id" was wrong! I hope this helps someone. You might be getting this error just because you put a non-existent property!

    0 讨论(0)
  • 2020-11-30 10:10

    I had a similar looking problem but with Rx and in my case adding

    using System;
    

    helped. FWIW

    Mess with those extension methods missing is too annoying sometimes.

    0 讨论(0)
  • 2020-11-30 10:14

    My issue involved the format:

    .Columns(columns => {
        columns.Bound(p => p.Id).Filterable(false);
        columns.Bound(p => p.Name).Width(250);
        ...
    

    Every p.Whatever had this error on it.

    This was a project using MVC, and I found my issue was having "public static int" or "public static string" on these variables (Id, Name, etc.) in my model. When I removed "static" on all my model variables, I no longer got the error. Was driving me nuts for about a day...

    0 讨论(0)
  • 2020-11-30 10:15

    i had the same problem with mvc 3 razor maybe someone has the same so i wanna show how to fix it in my stuation

    List<Taksit> lst = db.Taksit.Where(y => y.OgrenciId.Equals(Convert.ToInt32( list[0].Id))).ToList();
    

    i tried to use contains but hence OgrenciId is int i get the error mentioned here so by using equals the problem is solved

    0 讨论(0)
提交回复
热议问题