• Ask a Question
  • Create a Poll
150
    Ask a Question
    Cancel
    150
    More answer You can create 5 answer(s).
      Ask a Poll
      Cancel
      Jonconniesheri Earth
      260 points
      50 36
        • 0
        • 2
        • 0

        RE : Is there a way to indicate that a node is deprecated in an XML file?

        Asked on July 17, 2020 in XML.

        (1) You can use XML comments for that <!-- Document here whatever needed -->

        (2) It is better to use XSDs instead of DTDs. XSDs also have documentation dedicated tags. Please see below.

        <xsd:annotation>     <xsd:documentation>Document here whatever needed</xsd:documentation> </xsd:annotation> 
        • 330
        • 1
        • 0

        RE : How to get only distinct values from joined multiple tables

        Asked on July 16, 2020 in .NET.

        Distinct compared through what? Calling Distinct() without and IEqualityComparer does the same as if you normally use ==, meaning it looks if the references are equal. I’m guessing you want to compare by country name or country id, which means you’ll need a custom IEqualityComparer, luckily enough they’re quite easy to implement:

        class NewmodelEqualityComparer : IEqualityComparer<Newmodel> {     public bool Equals(Newmodel n1, Newmodel n2)     {         // Replace '.countries' with whatever property you want to compare         return n1.countries == n2.countries;     }      public int GetHashCode(Newmodel n)     {         return n.GetHashCode()     } } 

        Your call to Distinct then needs to simply pass this as its equality comparer, like so:

        .Distinct(new NewmodelEqualityComparer()).Take(100).ToList(); 

        Notice how I switched the positions of Take and ToList, this is because if you ToList first and then Take 100 the whole underlying original List will be processed and then 100 will be taken. We can make this a lot more efficient by first taking 100 and then converting the underlying collection to a list, saving potentially thousands of calls to Distinct. This is due to deferred execution provided by IEnumerable and LINQ

        • 392
        • 2
        • 0

        RE : ASP .Net Core: Many-to-Many relationship Get operation

        Asked on July 16, 2020 in .NET.

        You do not need the MovieActor class

        Change to:

        public class Movie  {      public int Id { get; set; }      public string Title { get; set; }       public List<Actor> Actors { get; set; }  }   public class Actor  {      public int Id { get; set; }      public string Name { get; set; }       public List<Movie> Movies { get; set; }  } 

        Then you can select the Actor and you have the list of Movies as a property on the actor.

        • 310
        • 1
        • 0

        RE : How do I round a number in SQLAlchemy and MySQL?

        Asked on July 16, 2020 in Mysql.

        SQLAlchemy allows producing (almost) any SQL function expression using the func utility:

        func.round(n, x) 
        • 278
        • 1
        • 0

        RE : MySQL 5.1 to 5.7 change Order By no longer working

        Asked on July 16, 2020 in Mysql.

        There is a problem with your sql_mode.

        As of MySQL 5.7.x, the default sql mode includes ONLY_FULL_GROUP_BY. (Before 5.7.5, MySQL does not detect functional dependency and ONLY_FULL_GROUP_BY is not enabled by default).

        ONLY_FULL_GROUP_BY: Non-deterministic grouping queries will be rejected

        For more details check the documentation of sql_mode

        Method 1:

        Check default value of sql_mode:

        SELECT @@sql_mode 

        Remove ONLY_FULL_GROUP_BY from console by executing below query:

        SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); 

        Method 2:

        Access phpmyadmin for editing your sql_mode

        • Login on phpmyadmin and open localhost
        • Top on Variables present on the top in menu items and search out for sql mode
        • Click on edit button to remove ONLY_FULL_GROUP_BY and save sql mode settings in phpmyadmin
        • 307
        • 4
        • 0

        RE : How to fix update select max id inner join other table

        Asked on July 16, 2020 in Mysql.

        Since you have not provided the join condition in your example, So after using a join condition between your tables(I am presuming that column as id), You may try below query on MySQL-

        UPDATE tb_joborderdetail q  INNER JOIN tb_survey as s ON q.id = s.id    SET s.survey_id = (SELECT MAX(s.survey_id) FROM tb_survey) + 1  WHERE q.id = 42 
        • 297
        • 3
        • 0

        RE : implementation of multiple if else condition in pandas data frame

        Asked on July 16, 2020 in Python.

        There is error in your code because of:

        x['is_good'] = x.apply(lambda row : selector(x), axis=1) 

        should be :

        x['is_good'] = x.apply(lambda row : selector(row), axis=1) 

        It was taking series not rows that’s why you got the error.

        • 317
        • 3
        • 0

        RE : Python, how to merge three dictionary in one filtering for key?

        Well, you where on the right track. Personally I would simply merge them:

        final_value = {} for key in personale_result:     final_value[key] = (personale_dip[key][0], personale_dip_costo[key][0], personal_result[key]) 

        With your input this will give you:

        >>> final_result {'a': [550.0, 1.0, 550.0], 'b': [157.65, 150.0, 23647.5]} 

        Now personale_dip and personale_dip_costo are of type {string, list}. Currently your personale_result will simply ignore other values in that list, as will final_result.

        • 328
        • 1
        • 0

        RE : How to access variable of type google.protobuf.Timestamp in python

        Asked on July 16, 2020 in Python.

        See here including an example using FromDateTime

        • 304
        • 1
        • 0

        RE : laravel contact form error Swift_TransportException

        You have MAIL_ENCRYPTION=465, you want to set it to:

        MAIL_ENCRYPTION=ssl