none
Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<AnonymousType#1>' to 'System.Collections.Generic.IEnumerable<AnonymousType#2>'

    Question

  • content = from a in db.LogFileMonitorContent3.ToList()
                                  where a.Message.Trim().ToUpper() != "ERROR MISSING"
                                  join b in db.LogFileMonitorPatterns.ToList()
                                  on a.SystemName.Trim().Replace(" ", "_") equals b.SubName.Trim().Replace(" ", "_")
                                  orderby a.MainSystemName, a.SystemName
                                  group a by a.SystemName into grp
                                  select new { grp.First().MainSystemName, grp.First().SystemName, grp.First().cfunction, grp.First().clogin, grp.First().date, grp.First().logger, grp.First().Loglevel, grp.First().propertyNDC, grp.First().Message, grp.First().threadID, grp.First().Namespace, grp.First().Class };

    got an error


    ---v-----!

    Thursday, October 17, 2013 8:59 AM

Answers

  • Hi zvzzvz;

    In your question you have a statement that starts as follows:

    context = from a in db.LogFileMonitorContent3 
                    select new ... ; 

    Somewhere before the variable "content" there has to be something like

    [Some Data Type] content = ... ;

    or something like this

    var content = ... ;

    Can you post that statement.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by oooooxxxxx Friday, October 18, 2013 2:17 AM
    Friday, October 18, 2013 1:54 AM

All replies

  • Hi zvzzvz;

    It sounds like the type of the variable content is of anAnonymous type which does not match the same Anonymous type being created by the select statement. Please post how the variable content was defined.

      


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Thursday, October 17, 2013 8:39 PM
  •  public partial class LogFileMonitorContent3
        {
            public string MainSystemName { get; set; }
            public string SystemName { get; set; }
            public string date { get; set; }
            public string threadID { get; set; }
            public string Loglevel { get; set; }
            public string logger { get; set; }
            public string propertyNDC { get; set; }
            public string clogin { get; set; }
            public string Namespace { get; set; }
            public string Class { get; set; }
            public string cfunction { get; set; }
            public string Message { get; set; }
            public int Seq { get; set; }
        }
    
    public partial class LogFileMonitorPattern
        {
            public string SystemName { get; set; }
            public string FilePath { get; set; }
            public string Pattern { get; set; }
            public string Limiter { get; set; }
            public string LogFileTime { get; set; }
            public string Frequency { get; set; }
            public string Responsible { get; set; }
            public string Remark { get; set; }
            public int EnableFlag { get; set; }
            public string SubName { get; set; }
            public string LogFileMonthly { get; set; }
            public string LogFileWeekly { get; set; }
        }


    ---v-----!

    Friday, October 18, 2013 1:12 AM
  • Hi zvzzvz;

    In your question you have a statement that starts as follows:

    context = from a in db.LogFileMonitorContent3 
                    select new ... ; 

    Somewhere before the variable "content" there has to be something like

    [Some Data Type] content = ... ;

    or something like this

    var content = ... ;

    Can you post that statement.


    Fernando (MCSD)

    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    • Marked as answer by oooooxxxxx Friday, October 18, 2013 2:17 AM
    Friday, October 18, 2013 1:54 AM
  • You are right. var can only use once, but second time i use without var


    ---v-----!






    • Edited by oooooxxxxx Friday, October 18, 2013 2:18 AM
    Friday, October 18, 2013 2:11 AM