Vongretchenmelissa's Profile

250
Points

Questions
48

Answers
45

  • Asked on July 16, 2020 in .NET.

    Yes, the NuSpec file inside your package will contain the contentFiles tag unless you define a custom PackagePath for your resources in the project file. It guess that this behavior applies to .csproj files, because the default path for content files is overwritten for that file and it is no longer detected as content file applying to NuGet conventions. From the .csproj reference and MS Build targets:

    This property specifies the default location of where all the content files should go if PackagePath is not specified for them. The default value is "content;contentFiles".

    By default, everything gets added to the root of the content and contentFiles\any<target_framework> folder within a package and preserves the relative folder structure, unless you specify a package path […]

    Although it is explcitly stated that you can use the PackagePath on a lot of content types with different build actions, there is no mention that this results in a different NuSpec file, but in practice it does.

    Apart from Content items, the and metadata can also be set on files with a build action of Compile, EmbeddedResource, ApplicationDefinition, Page, Resource, SplashScreen, DesignData, DesignDataWithDesignTimeCreateableTypes, CodeAnalysisDictionary, AndroidAsset, AndroidResource, BundleResource or None. […]

    In your csproj file, tags like None and Content determine the build action and therefore whether your image file is embedded, copied to the output folder or anything else. However, apart from the original issue, setting Pack="true" is enough to automatically include it in the contenFiles\any\<Target framework moniker> folder in your package. Setting PackageCopyToOutput="true" will copy it to the consuming project’s output directory.

    • 344 views
    • 1 answers
    • 0 votes

  • EF Core treat Date as an Entity Type, instead of a property of an Entity.

    Only in this situation could I use DateTime instead, no problem. But could I find out an alternate solution every time?

    Rather than convert it to a DateTime, which may work in this case but not all cases, you can register your value object as a complex type

    This means that EF will interpret your Date object as a "bag of properties" of the Student object that owns it, rather than as a separate entity of its own. In short, it will create a table column (in the parent entity table, e.g. [Students]) for every public property (day, month, year).

    However, that does come with the requirement of needing to have setters on your properties and a parameterless constructor, otherwise EF cannot render your value object from the database.

    In cases where there is no equivalent data type that EF can handle (such as DateTime for Date), this is the better option.

    • 335 views
    • 2 answers
    • 0 votes
  • Using the Combine method from this post does pretty much everything you need. From there you just need to turn the literal value into an expression that computes it (or I guess alter the Combine method from that answer so that the intermediate value isn’t computed from a lambda but rather is just any expression), and then call the function.

    protected IEnumerable<TColumn> FilterIds; protected Expression<Func<T, IEnumerable<TColumn>> FilterIdsExpression => _ => FilterIds; protected Expression<Func<T, IEnumerable<TColumn>, bool>> Filter;  public virtual IQueryable<T> ApplyFilter(IQueryable<T> query) {     if (FilterMode == FilterModeMatchAny && HasFilterIds)     {         return query.Where(FilterIdsExpression.Combine(Filter));     }     return query; } 
    • 348 views
    • 2 answers
    • 0 votes
  • You are look for FIND_IN_SET

    Returns a value in the range of 1 to N if the string str is in the string list strlist consisting of N substrings. A string list is a string composed of substrings separated by , characters

    mysql> DESCRIBE products; +---------+------------------+------+-----+---------+----------------+ | Field   | Type             | Null | Key | Default | Extra          | +---------+------------------+------+-----+---------+----------------+ | id      | int(11) unsigned | NO   | PRI | NULL    | auto_increment | | product | varchar(255)     | YES  |     | NULL    |                | | selling | varchar(255)     | YES  |     | NULL    |                | +---------+------------------+------+-----+---------+----------------+ 3 rows in set (0.00 sec)    mysql> SELECT * FROM products; +----+---------+---------------------------+ | id | product | selling                   | +----+---------+---------------------------+ |  1 | carpet  | new,discounted,hello,worl | |  2 | fork    | used,other                | |  3 | plate   | new                       | |  4 | spoon   | NULL                      | +----+---------+---------------------------+ 4 rows in set (0.00 sec)   mysql> SELECT * FROM products     -> WHERE product='carpet' AND FIND_IN_SET('new', selling) <> 0; +----+---------+---------------------------+ | id | product | selling                   | +----+---------+---------------------------+ |  1 | carpet  | new,discounted,hello,worl | +----+---------+---------------------------+ 1 row in set (0.00 sec) 
    • 335 views
    • 2 answers
    • 0 votes
  • Asked on July 16, 2020 in Mysql.

    It is failing because the account is created with no password. The MySQL docs have an example.

    This account-creation statement fails, even though the account is locked initially, because it does not include a password that satisfies the current password policy:

    mysql> CREATE USER 'juanita'@'localhost' ACCOUNT LOCK; ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 

    You must create a user with their password.

    create user 'support_usr'@'gk1qYu!n%' identified by 'Pxuzj#1M4!d' ; 

    You have variables for two different versions of MySQL. Prior to MySQL 8, they were validate_password_xxx. MySQL 8 changed this to validate_password.xxx. MySQL 8 has instructions on how to transition from the old to the new.

    • 0 views
    • 1 answers
    • 0 votes
  • In your query, you just need to add the property where within the scope property, like this:

    return this.htcApi.find({   include: [     {       relation: 'nmos',       scope: {         include: 'countries',         where: {           and [             { id: htc.n_id },             { name: 'abc' },           ],         },       },     },   ],   where: { name: 'abc' } }); 

    This should return the htcApi objects named ‘abc’ with the related nmos objects that have the name ‘abc’ and the id ‘n_id’.

    • 283 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    If the company name look the ‘same’ then you have whitespace at front or end, I am adding the upper convert all to upper case as well.

    freq = df.groupby(df['company'].str.strip().str.upper())['recruitment'].size() 
    • 273 views
    • 1 answers
    • 0 votes
  • Asked on July 16, 2020 in Python.

    With Python modules sometimes they are separated as to force the user to import submodules explicitly as to not clutter the namespace and reduce memory usage when loading modules that have many submodules attached to them.

    • 317 views
    • 1 answers
    • 0 votes
    • 384 views
    • 5 answers
    • 0 votes
  • Like others have states, you first need to have the CORS configuration in your S3 bucket:

    <CORSConfiguration> <CORSRule>     <AllowedOrigin>*</AllowedOrigin>     <AllowedMethod>GET</AllowedMethod>     <AllowedMethod>HEAD</AllowedMethod> <!-- Add this -->     <MaxAgeSeconds>3000</MaxAgeSeconds>     <AllowedHeader>Authorization</AllowedHeader> </CORSRule> </CORSConfiguration> 

    But in my case after doing that, it was still not working. I was using Chrome (probably the same problem with other browsers).

    The problem was that Chrome was caching the image with the headers (not containing the CORS data), so no matter what I tried to change in AWS, I would not see my CORS headers.

    After clearing Chrome cache and reloading the page, the image had the expected CORS Headers

    • 795 views
    • 23 answers
    • 0 votes