朱染

文章 评论 浏览 32

朱染 2025-02-20 15:53:52

您必须在详细信息中修复EF代码

var model= await context...
.Include(r=> r.Region)
...

you have to fix you ef code in Details action

var model= await context...
.Include(r=> r.Region)
...

System.NullReferenceException创建一个详细信息查看站点模型,该模型来自区域模型

朱染 2025-02-20 09:58:37

我不确定您要做什么,但是也许使用CustomListItem创建列表或Treelist会为您提供更多帮助。
您可以将其放入SplitApp中,并具有“导航”面板,但可以完全自定义。

I'm not sure what you are trying to do, but maybe creating a List or TreeList with a CustomListItem would help you more.
You can put it into a SplitApp and have a "Navigation like" Panel too, but fully customizable.

有没有办法在SAPUI5中的侧边栏中插入复选框和组合?

朱染 2025-02-20 03:32:39

这很简单。 可以使用 column()使用 mainaxisAlignment mainaxisalignment.center.center

Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          "P O M O D O N E",
          style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 22,
            color: Color(0xff313640),
          ),
        ),
        Text('click me')
      ],
    )

由于您想要一个小部件下方的一个小部件,因此 要删除 center()窗口小部件代替 column()

使用您的代码,一个完整的可运行示例:

import 'package:braintrinig/pages/log_in.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffF24004),
      body: Center(
        child: Container(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              GestureDetector(
                onTap: () {
                  print("Container clicked");
                  Navigator.pushReplacement(
                      context, MaterialPageRoute(builder: (_) => LogIn()));
                },
                child: Container(
                  width: 202,
                  height: 196,
                  margin: EdgeInsets.all(100.0),
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: Color(0xffF2B749),
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text("P O M O D O N E", style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 22,
                        color: Color(0xff313640),
                      ),),
                      Text('Click me')
                    ],
                  ),
                ),
              ),
              Center(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Container(
                      width: 75,
                      height: 112,
                      child: Icon(Icons.check_rounded,
                        size: 100,
                        color: Color(0xffF3F5F4),
                      ),
                    ),
                  ],
                ),
              ) // Add Another Icon Here
            ],
          ),
        ),
      ),
    );
  }
}

我建议您花时间阅读

It's quite simple. Since you want one widget below another one, you can use a Column() with setting the mainAxisAlignment to MainAxisAlignment.center:

Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text(
          "P O M O D O N E",
          style: TextStyle(
            fontWeight: FontWeight.bold,
            fontSize: 22,
            color: Color(0xff313640),
          ),
        ),
        Text('click me')
      ],
    )

You'll have to remove the Center() widget in place of the Column().

Using your code, a complete runnable example:

import 'package:braintrinig/pages/log_in.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xffF24004),
      body: Center(
        child: Container(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              GestureDetector(
                onTap: () {
                  print("Container clicked");
                  Navigator.pushReplacement(
                      context, MaterialPageRoute(builder: (_) => LogIn()));
                },
                child: Container(
                  width: 202,
                  height: 196,
                  margin: EdgeInsets.all(100.0),
                  decoration: BoxDecoration(
                    shape: BoxShape.circle,
                    color: Color(0xffF2B749),
                  ),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      Text("P O M O D O N E", style: TextStyle(
                        fontWeight: FontWeight.bold,
                        fontSize: 22,
                        color: Color(0xff313640),
                      ),),
                      Text('Click me')
                    ],
                  ),
                ),
              ),
              Center(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Container(
                      width: 75,
                      height: 112,
                      child: Icon(Icons.check_rounded,
                        size: 100,
                        color: Color(0xffF3F5F4),
                      ),
                    ),
                  ],
                ),
              ) // Add Another Icon Here
            ],
          ),
        ),
      ),
    );
  }
}

I suggest you take your time to read the official documentation on Layouts in Flutter.

如何在下面添加文本“ pomodone”在扑来?

朱染 2025-02-19 17:13:02

不,您不能使用 sizeof(ptr)查找数组的大小 ptr 指向。

尽管要在额外的空间中存储长度,但分配额外的内存(大于数组的大小)将有所帮助。

No, you can't use sizeof(ptr) to find the size of array ptr is pointing to.

Though allocating extra memory(more than the size of array) will be helpful if you want to store the length in extra space.

如何找到数组的大小(从指向第一个元素数组的指针)?

朱染 2025-02-19 12:04:18

一种选项是,您可以将REGEX与 split()方法一起使用,或者使用 match()方法而不是使用Regex。正则表达式将根据您选择使用的方法而有所不同。

const data = `with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","userid=&aplus&ali_beacon_id=&ali_apache_id=&ali_apache_track=&ali_apache_tracktmp=&dmtrack_c={}&hn=aeproductsourcesite033001217071%2eus44&asid=AQAAAADkyhRi8NcdZwAAAABHROT4NDi+yA==&sidx=Fzc+BeTKFGIAAAAA0uvd1jNUkicntMPM",id="beacon-aplus",src="//assets.alicdn.com/g/alilog/??aplus_plugin_aefront/index.js,mlog/aplus_v2.js")

Package included:1 Dress
Material:100% Cotton
Colors:Beige,Navy,Light Green,Pink
Size:S,M,L,XL,2XL,,,
Sleeve Length:Full Sleeve
Neckline:Square Neck
Pattern: Solid Color
Length:Ankle Length
Thickness:Thin
Decoration:Side Pockets
Style:Leisure,Bohemian,Retro,Europe
Season:Spring,Summer,Autumn
Occasion:Family,Holiday,Employment,Travel`;

const removeWithSplit = (data) => data.split(/(\n|\r){2,}/).pop();

const removeWithMatch = (data) => data.match(/(\w\s?)+:.*/g)?.join('\n');

console.log('**WITH SPLIT**');
console.log(removeWithSplit(data), '\n');

console.log('**WITH MATCH**');
console.log(removeWithMatch(data), '\n');

奖励:

这是一个api返回此纯文本的bummer。可以改用JSON吗?如果没有,这是一种将其结果转换为对象的方法:

const data = `with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","userid=&aplus&ali_beacon_id=&ali_apache_id=&ali_apache_track=&ali_apache_tracktmp=&dmtrack_c={}&hn=aeproductsourcesite033001217071%2eus44&asid=AQAAAADkyhRi8NcdZwAAAABHROT4NDi+yA==&sidx=Fzc+BeTKFGIAAAAA0uvd1jNUkicntMPM",id="beacon-aplus",src="//assets.alicdn.com/g/alilog/??aplus_plugin_aefront/index.js,mlog/aplus_v2.js")

Package included:1 Dress
Material:100% Cotton
Colors:Beige,Navy,Light Green,Pink
Size:S,M,L,XL,2XL,,,
Sleeve Length:Full Sleeve
Neckline:Square Neck
Pattern: Solid Color
Length:Ankle Length
Thickness:Thin
Decoration:Side Pockets
Style:Leisure,Bohemian,Retro,Europe
Season:Spring,Summer,Autumn
Occasion:Family,Holiday,Employment,Travel`;

const removeWithMatch = (data: string) => data.match(/(\w\s?)+:.*/g)?.join('\n');

const resultsToObject = (data: string) => {
    return data.split('\n').reduce((acc, curr) => {
        const [key, value] = curr.split(':');

        return {
            ...acc,
            [key]: value,
        };
    }, {} as Record<string, unknown>);
};

console.log(resultsToObject(removeWithMatch(data) as string));

One options is that you can use regex with either the split() method, or using the match() method instead. The regular expression will vary based on the method you choose to use.

const data = `with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","userid=&aplus&ali_beacon_id=&ali_apache_id=&ali_apache_track=&ali_apache_tracktmp=&dmtrack_c={}&hn=aeproductsourcesite033001217071%2eus44&asid=AQAAAADkyhRi8NcdZwAAAABHROT4NDi+yA==&sidx=Fzc+BeTKFGIAAAAA0uvd1jNUkicntMPM",id="beacon-aplus",src="//assets.alicdn.com/g/alilog/??aplus_plugin_aefront/index.js,mlog/aplus_v2.js")

Package included:1 Dress
Material:100% Cotton
Colors:Beige,Navy,Light Green,Pink
Size:S,M,L,XL,2XL,,,
Sleeve Length:Full Sleeve
Neckline:Square Neck
Pattern: Solid Color
Length:Ankle Length
Thickness:Thin
Decoration:Side Pockets
Style:Leisure,Bohemian,Retro,Europe
Season:Spring,Summer,Autumn
Occasion:Family,Holiday,Employment,Travel`;

const removeWithSplit = (data) => data.split(/(\n|\r){2,}/).pop();

const removeWithMatch = (data) => data.match(/(\w\s?)+:.*/g)?.join('\n');

console.log('**WITH SPLIT**');
console.log(removeWithSplit(data), '\n');

console.log('**WITH MATCH**');
console.log(removeWithMatch(data), '\n');

Bonus:

It's a bummer the API returns this plain text. Is it possible to get JSON back instead? If not, here's a way to convert its results into an object:

const data = `with(document)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("exparams","userid=&aplus&ali_beacon_id=&ali_apache_id=&ali_apache_track=&ali_apache_tracktmp=&dmtrack_c={}&hn=aeproductsourcesite033001217071%2eus44&asid=AQAAAADkyhRi8NcdZwAAAABHROT4NDi+yA==&sidx=Fzc+BeTKFGIAAAAA0uvd1jNUkicntMPM",id="beacon-aplus",src="//assets.alicdn.com/g/alilog/??aplus_plugin_aefront/index.js,mlog/aplus_v2.js")

Package included:1 Dress
Material:100% Cotton
Colors:Beige,Navy,Light Green,Pink
Size:S,M,L,XL,2XL,,,
Sleeve Length:Full Sleeve
Neckline:Square Neck
Pattern: Solid Color
Length:Ankle Length
Thickness:Thin
Decoration:Side Pockets
Style:Leisure,Bohemian,Retro,Europe
Season:Spring,Summer,Autumn
Occasion:Family,Holiday,Employment,Travel`;

const removeWithMatch = (data: string) => data.match(/(\w\s?)+:.*/g)?.join('\n');

const resultsToObject = (data: string) => {
    return data.split('\n').reduce((acc, curr) => {
        const [key, value] = curr.split(':');

        return {
            ...acc,
            [key]: value,
        };
    }, {} as Record<string, unknown>);
};

console.log(resultsToObject(removeWithMatch(data) as string));

删除不需要的文字

朱染 2025-02-19 04:21:24

问题在这里:

    bookmaker.markets[0].outcomes.forEach(outcome => {
      matchesAndOdds[i].odds[bookmaker.title] = {};

这将重置奇数[bookmaker.title] 在每次迭代中, utemes 中的对象。这将破坏该循环先前迭代的结果。此初始化应该在循环之前发生

    matchesAndOdds[i].odds[bookmaker.title] = {};
    bookmaker.markets[0].outcomes.forEach(outcome => {

您实际上可以用“更好”的代码进行过程:

const odds =[{"id": "dd7aff0584aee475b4d67ab83655f379","sport_key": "aussierules_afl","sport_title": "AFL","commence_time": "2022-06-30T09:20:00Z","home_team": "Brisbane Lions","away_team": "Western Bulldogs","bookmakers": [{"key": "unibet","title": "Unibet","last_update": "2022-06-29T12:14:33Z","markets": [{"key": "h2h","outcomes": [{"name": "Brisbane Lions","price": 1.36},{"name": "Western Bulldogs","price": 3.15}]}]}]}]
const matches =[{gametime: "2022-06-30T09:20:00.000Z",home_team: 'Brisbane Lions',away_team: 'Western Bulldogs',ground: 'Gabba',home_points: 108,away_points: 67,selected: null}]
const ffToOa = {"Western Bulldogs": "Western Bulldogs","Brisbane Lions": "Brisbane Lions","St Kilda": "St Kilda Saints","Carlton": "Carlton Blues","Sydney": "Sydney Swans","Essendon": "Essendon Bombers","Melbourne": "Melbourne Demons","Naarm": "Melbourne Demons","Adelaide": "Adelaide Crows","North Melbourne": "North Melbourne Kangaroos","Geelong": "Geelong Cats","Collingwood": "Collingwood Magpies","Gold Coast": "Gold Coast Suns","West Coast": "West Coast Eagles","Richmond": "Richmond Tigers","Hawthorn": "Hawthorn Hawks","GWS": "Greater Western Sydney Giants","Port Adelaide": "Port Adelaide Power","Fremantle": "Fremantle Dockers"}

const matchesAndOdds = matches.map(match => {
  const {home_team, bookmakers} = odds.find(odd =>
    odd.home_team === ffToOa[match.home_team] &&
    odd.away_team === ffToOa[match.away_team]
  ) ?? {};
  return home_team ? {
    ...match, 
    odds: Object.fromEntries(bookmakers.map(({title, markets: [{outcomes}]}) => [
      title,
      Object.fromEntries(outcomes.map(outcome =>
        [outcome.name === home_team ? "home" : "away", outcome.price]
      ))
    ]))
  } : match;
});

console.log(matchesAndOdds);

The problem is here:

    bookmaker.markets[0].outcomes.forEach(outcome => {
      matchesAndOdds[i].odds[bookmaker.title] = {};

This resets the odds[bookmaker.title] object in every iteration over outcomes. This will destroy the results from the previous iteration of this loop. This initialisation should happen before the loop:

    matchesAndOdds[i].odds[bookmaker.title] = {};
    bookmaker.markets[0].outcomes.forEach(outcome => {

You can actually make the process with a bit "nicer" code:

const odds =[{"id": "dd7aff0584aee475b4d67ab83655f379","sport_key": "aussierules_afl","sport_title": "AFL","commence_time": "2022-06-30T09:20:00Z","home_team": "Brisbane Lions","away_team": "Western Bulldogs","bookmakers": [{"key": "unibet","title": "Unibet","last_update": "2022-06-29T12:14:33Z","markets": [{"key": "h2h","outcomes": [{"name": "Brisbane Lions","price": 1.36},{"name": "Western Bulldogs","price": 3.15}]}]}]}]
const matches =[{gametime: "2022-06-30T09:20:00.000Z",home_team: 'Brisbane Lions',away_team: 'Western Bulldogs',ground: 'Gabba',home_points: 108,away_points: 67,selected: null}]
const ffToOa = {"Western Bulldogs": "Western Bulldogs","Brisbane Lions": "Brisbane Lions","St Kilda": "St Kilda Saints","Carlton": "Carlton Blues","Sydney": "Sydney Swans","Essendon": "Essendon Bombers","Melbourne": "Melbourne Demons","Naarm": "Melbourne Demons","Adelaide": "Adelaide Crows","North Melbourne": "North Melbourne Kangaroos","Geelong": "Geelong Cats","Collingwood": "Collingwood Magpies","Gold Coast": "Gold Coast Suns","West Coast": "West Coast Eagles","Richmond": "Richmond Tigers","Hawthorn": "Hawthorn Hawks","GWS": "Greater Western Sydney Giants","Port Adelaide": "Port Adelaide Power","Fremantle": "Fremantle Dockers"}

const matchesAndOdds = matches.map(match => {
  const {home_team, bookmakers} = odds.find(odd =>
    odd.home_team === ffToOa[match.home_team] &&
    odd.away_team === ffToOa[match.away_team]
  ) ?? {};
  return home_team ? {
    ...match, 
    odds: Object.fromEntries(bookmakers.map(({title, markets: [{outcomes}]}) => [
      title,
      Object.fromEntries(outcomes.map(outcome =>
        [outcome.name === home_team ? "home" : "away", outcome.price]
      ))
    ]))
  } : match;
});

console.log(matchesAndOdds);

JS对象的属性可以在循环中覆盖吗?

朱染 2025-02-19 00:36:38

我已经处理了以下错误,以“ typeorm”:“ 0.3.6”,以前,因此希望我的经验与您相关。

而不是使用 getManager 我正在使用 entityManager ,但结果是相同的。

这是您的情况的示例:

test.module.ts

@Module({
  imports: [
    TypeOrmModule.forRoot(postgresConfig), // <- connection configs
    TypeOrmModule.forFeature([
      TestEntity,
    ]),
  ],
  controllers: [],
  providers: [TestService],
})
export class TestModule {}

test.service.ts

@Injectable()
export class TestService implements OnApplicationBootstrap {
  constructor(
    @InjectEntityManager()
    private readonly entityManager: EntityManager,
  )

  async onApplicationBootstrap(): Promise<void> {
    const count = await this.entityManager.getRepository(TestEntity).count('query');
    console.log(count);
  }
}

您还应该为此创建一个Typeorm实体。

如果我们谈论迁移,则可以使用 ormconfig.json ,但使用TypeOmm与Jest等测试框架相结合的问题,如果您与之相关,只需提及它,并且我会在项目中找到一个例子。

它应该与没有装饰器的无需装饰的手动连接有关:

export const getDatabaseConnectionOptions = (config): PostgresConnectionOptions => {
    return {
        type: 'postgres',
        logging: config.db.logging,
        connectTimeoutMS: config.db.master.connectionTimeoutMillis,
        uuidExtension: 'uuid-ossp',
        extra: {
            idleTimeoutMillis: config.db.master.idleTimeoutMillis,
            max: config.db.master.max,
            keepalives_idle: config.db.master.keepalives_idle,
        },
        entities: process.env.TS_NODE
            ? [path.join(process.cwd(), 'src/**/*.entity.ts')]
            : [path.join(process.cwd(), 'dist/**/*.entity.js')],
        migrations: process.env.TS_NODE ? ['src/typeorm_migrations/*.ts'] : ['dist/typeorm_migrations/*.js'],
        migrationsTableName: 'typeorm_migrations',
        namingStrategy: new DatabaseNamingStrategy(),
        replication: {
            master: {
                host: config.db.master.host,
                port: config.db.master.port,
                username: config.db.master.user,
                password: config.db.master.password,
                database: config.db.master.database,
            },
            slaves: [
                {
                    host: config.db.slave.host,
                    port: config.db.slave.port,
                    username: config.db.slave.user,
                    password: config.db.slave.password,
                    database: config.db.slave.database,
                },
            ],
        },
        cli: {
            migrationsDir: 'src/typeorm_migrations',
        },
    };
};

export const createDatabaseConnection = async (config): Promise<Connection> => {
    // Setup TypeDI
    useContainer(Container);

    // Setup typeorm-transactional-cls-hooked
    initializeTransactionalContext();
    patchTypeORMRepositoryWithBaseRepository();

    return await createConnection(config);
};
    const connection = await createDatabaseConnection(getDatabaseConnectionOptions(config));
    const { app } = createAppApi();

然后通过 Connection props访问经理或实体。

I have dealt with the following error with "typeorm": "0.3.6", before, so hopes that my experience will be relevant for you.

Instead of using getManager I am using entityManager but result is the same.

Here is the example for your case:

test.module.ts

@Module({
  imports: [
    TypeOrmModule.forRoot(postgresConfig), // <- connection configs
    TypeOrmModule.forFeature([
      TestEntity,
    ]),
  ],
  controllers: [],
  providers: [TestService],
})
export class TestModule {}

test.service.ts

@Injectable()
export class TestService implements OnApplicationBootstrap {
  constructor(
    @InjectEntityManager()
    private readonly entityManager: EntityManager,
  )

  async onApplicationBootstrap(): Promise<void> {
    const count = await this.entityManager.getRepository(TestEntity).count('query');
    console.log(count);
  }
}

You should also have created a typeorm entities for that.

If we are talking about migrations you could use an ormconfig.json, but also there was a problem with using typeorm combined with test frameworks like Jest and if you case is relevant with it, just mention it, and I'll find an example in on of my projects.

It should be something relevant with creating manual connections without decorator like:

export const getDatabaseConnectionOptions = (config): PostgresConnectionOptions => {
    return {
        type: 'postgres',
        logging: config.db.logging,
        connectTimeoutMS: config.db.master.connectionTimeoutMillis,
        uuidExtension: 'uuid-ossp',
        extra: {
            idleTimeoutMillis: config.db.master.idleTimeoutMillis,
            max: config.db.master.max,
            keepalives_idle: config.db.master.keepalives_idle,
        },
        entities: process.env.TS_NODE
            ? [path.join(process.cwd(), 'src/**/*.entity.ts')]
            : [path.join(process.cwd(), 'dist/**/*.entity.js')],
        migrations: process.env.TS_NODE ? ['src/typeorm_migrations/*.ts'] : ['dist/typeorm_migrations/*.js'],
        migrationsTableName: 'typeorm_migrations',
        namingStrategy: new DatabaseNamingStrategy(),
        replication: {
            master: {
                host: config.db.master.host,
                port: config.db.master.port,
                username: config.db.master.user,
                password: config.db.master.password,
                database: config.db.master.database,
            },
            slaves: [
                {
                    host: config.db.slave.host,
                    port: config.db.slave.port,
                    username: config.db.slave.user,
                    password: config.db.slave.password,
                    database: config.db.slave.database,
                },
            ],
        },
        cli: {
            migrationsDir: 'src/typeorm_migrations',
        },
    };
};

export const createDatabaseConnection = async (config): Promise<Connection> => {
    // Setup TypeDI
    useContainer(Container);

    // Setup typeorm-transactional-cls-hooked
    initializeTransactionalContext();
    patchTypeORMRepositoryWithBaseRepository();

    return await createConnection(config);
};
    const connection = await createDatabaseConnection(getDatabaseConnectionOptions(config));
    const { app } = createAppApi();

and then access to managers or entities via connection props.

@nestjs/typeorm如何在自定义装饰器中与typeorm的v0.3.0进行当前连接?

朱染 2025-02-18 14:25:36

目前,直到EFCORE有新的东西,我才会使用命令
并将其手动绘制

  using (var command = this.DbContext.Database.GetDbConnection().CreateCommand())
  {
      command.CommandText = "SELECT ... WHERE ...> @p1)";
      command.CommandType = CommandType.Text;
      var parameter = new SqlParameter("@p1",...);
      command.Parameters.Add(parameter);

      this.DbContext.Database.OpenConnection();

      using (var result = command.ExecuteReader())
      {
         while (result.Read())
         {
            .... // Map to your entity
         }
      }
  }

尝试SQLPARAMETER,以避免注入SQL。

 dbData.Product.FromSql("SQL SCRIPT");

FROFSQL无法使用完整查询。例如,如果要包含一个Were子句,它将被忽略。

一些链接:

使用Entity Framework core 执行RAW SQL查询

.microsoft.com/en-us/ef/core/querying/raw-sql“ rel =“ noreferrer”> RAW SQL查询

For now, until there is something new from EFCore I would used a command
and map it manually

  using (var command = this.DbContext.Database.GetDbConnection().CreateCommand())
  {
      command.CommandText = "SELECT ... WHERE ...> @p1)";
      command.CommandType = CommandType.Text;
      var parameter = new SqlParameter("@p1",...);
      command.Parameters.Add(parameter);

      this.DbContext.Database.OpenConnection();

      using (var result = command.ExecuteReader())
      {
         while (result.Read())
         {
            .... // Map to your entity
         }
      }
  }

Try to SqlParameter to avoid Sql Injection.

 dbData.Product.FromSql("SQL SCRIPT");

FromSql doesn't work with full query. Example if you want to include a WHERE clause it will be ignored.

Some Links:

Executing Raw SQL Queries using Entity Framework Core

Raw SQL Queries

RAW SQL查询无DBSET-实体框架核心

朱染 2025-02-18 12:22:47

为什么不使用GitLab的扩展或参考关键字?

---
include:
  - local: '/templates/test-template.yml'

example-stage:
  script:
    - !reference [.test-script, script]

或者

---
include:
  - local: '/templates/test-template.yml'

example-stage:
  extends: .test-script

Why not use GitLab's extends or reference keywords?

---
include:
  - local: '/templates/test-template.yml'

example-stage:
  script:
    - !reference [.test-script, script]

or

---
include:
  - local: '/templates/test-template.yml'

example-stage:
  extends: .test-script

如何在.gitlab-ci.yml中使用模板中的脚本

朱染 2025-02-18 11:16:13

即使您缺少对,也不需要排序( as.matrix(dat1)[,1:2] 可以用 cbind(dat1 [,1],, dat1 [,2])):

> set.seed(45);dat1=data.frame(name=rep(c("firstName","secondName"),each=4),numbers=rep(1:4,2),value=rnorm(8))
> u1=unique(dat1[,1]);u2=unique(dat1[,2])
> m=matrix(nrow=length(u1),ncol=length(u2),dimnames=list(u1,u2))
> m[as.matrix(dat1)[,1:2]]=dat1[,3]
> m
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

如果您缺少对并且需要排序,这是不起作用的,但是如果对已经进行了排序,则有点短:

> u1=unique(dat1[,1]);u2=unique(dat1[,2])
> dat1=dat1[order(dat1[,1],dat1[,2]),] # not actually needed in this case
> matrix(dat1[,3],length(u1),,T,list(u1,u2))
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

这是第一个方法的函数版本(添加) as.data.frame 使其与tibbles一起使用):

l2w=function(x,row=1,col=2,val=3,sort=F){
  u1=unique(x[,row])
  u2=unique(x[,col])
  if(sort){u1=sort(u1);u2=sort(u2)}
  out=matrix(nrow=length(u1),ncol=length(u2),dimnames=list(u1,u2))
  out[cbind(x[,row],x[,col])]=x[,val]
  out
}

或者,如果您只有下三角的值,则可以做到这一点:

> euro=as.matrix(eurodist)[1:3,1:3]
> lower=data.frame(V1=rownames(euro)[row(euro)[lower.tri(euro)]],V2=colnames(euro)[col(euro)[lower.tri(euro)]],V3=euro[lower.tri(euro)])
> lower
         V1        V2   V3
1 Barcelona    Athens 3313
2  Brussels    Athens 2963
3  Brussels Barcelona 1318
> n=unique(c(lower[,1],lower[,2]))
> full=rbind(lower,setNames(lower[,c(2,1,3)],names(lower)),data.frame(V1=n,V2=n,V3=0))
> full
         V1        V2   V3
1 Barcelona    Athens 3313
2  Brussels    Athens 2963
3  Brussels Barcelona 1318
4    Athens Barcelona 3313
5    Athens  Brussels 2963
6 Barcelona  Brussels 1318
7    Athens    Athens    0
8 Barcelona Barcelona    0
9  Brussels  Brussels    0
> l2w(full,sort=T)
          Athens Barcelona Brussels
Athens         0      3313     2963
Barcelona   3313         0     1318
Brussels    2963      1318        0

或以下是另一种方法:

> rc=as.matrix(lower[-3])
> n=sort(unique(c(rc)))
> m=matrix(0,length(n),length(n),,list(n,n))
> m[rc]=lower[,3]
> m[rc[,2:1]]=lower[,3]
> m
          Athens Barcelona Brussels
Athens         0      3313     2963
Barcelona   3313         0     1318
Brussels    2963      1318        0

基本R中的另一种简单方法是使用 XTABS XTABS 的结果基本上只是一个带有精美类名称的矩阵,但是您可以使其看起来像常规矩阵,带有 class(x)= null; attr; attr; attr; attr; attr; attr; attr(x,“ call'call'' )= null; dimNames(x)= unname(dimnames(x))

> x=xtabs(value~name+numbers,dat1);x
            numbers
name                  1          2          3          4
  firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
  secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357
> str(x)
 'xtabs' num [1:2, 1:4] 0.341 -0.898 -0.703 -0.335 -0.38 ...
 - attr(*, "dimnames")=List of 2
  ..$ name   : chr [1:2] "firstName" "secondName"
  ..$ numbers: chr [1:4] "1" "2" "3" "4"
 - attr(*, "call")= language xtabs(formula = value ~ name + numbers, data = dat1)
> class(x)
[1] "xtabs" "table"
> class(as.matrix(x)) # `as.matrix` has no effect because `x` is already a matrix
[1] "xtabs" "table"
> class(x)=NULL;class(x)
[1] "matrix" "array"
> attr(x,"call")=NULL;dimnames(x)=unname(dimnames(x))
> x # now it looks like a regular matrix
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357
> str(x)
 num [1:2, 1:4] 0.341 -0.898 -0.703 -0.335 -0.38 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:2] "firstName" "secondName"
  ..$ : chr [1:4] "1" "2" "3" "4"

正常 as.data.frame(x)转换 XTABS back的结果要长时间格式,但是您可以使用 class(x)= null :这可以避免使用它:

> x=xtabs(value~name+numbers,dat1);as.data.frame(x)
        name numbers       Freq
1  firstName       1  0.3407997
2 secondName       1 -0.8981073
3  firstName       2 -0.7033403
4 secondName       2 -0.3347941
5  firstName       3 -0.3795377
6 secondName       3 -0.5013782
7  firstName       4 -0.7460474
8 secondName       4 -0.1745357
> class(x)=NULL;as.data.frame(x)
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

这将以宽阔的格式转换到长格式( linrist 将dataframe转换为vector和<代码> C 将矩阵转换为向量):

w2l=function(x)data.frame(V1=rownames(x)[row(x)],V2=colnames(x)[col(x)],V3=unname(c(unlist(x))))

This works even if you have missing pairs and it doesn't require sorting (as.matrix(dat1)[,1:2] can be replaced with cbind(dat1[,1],dat1[,2])):

> set.seed(45);dat1=data.frame(name=rep(c("firstName","secondName"),each=4),numbers=rep(1:4,2),value=rnorm(8))
> u1=unique(dat1[,1]);u2=unique(dat1[,2])
> m=matrix(nrow=length(u1),ncol=length(u2),dimnames=list(u1,u2))
> m[as.matrix(dat1)[,1:2]]=dat1[,3]
> m
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

This doesn't work if you have missing pairs and it requires sorting, but it's a bit shorter in case the pairs are already sorted:

> u1=unique(dat1[,1]);u2=unique(dat1[,2])
> dat1=dat1[order(dat1[,1],dat1[,2]),] # not actually needed in this case
> matrix(dat1[,3],length(u1),,T,list(u1,u2))
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

Here's a function version of the first approach (add as.data.frame to make it work with tibbles):

l2w=function(x,row=1,col=2,val=3,sort=F){
  u1=unique(x[,row])
  u2=unique(x[,col])
  if(sort){u1=sort(u1);u2=sort(u2)}
  out=matrix(nrow=length(u1),ncol=length(u2),dimnames=list(u1,u2))
  out[cbind(x[,row],x[,col])]=x[,val]
  out
}

Or if you only have the values of the lower triangle, you can do this:

> euro=as.matrix(eurodist)[1:3,1:3]
> lower=data.frame(V1=rownames(euro)[row(euro)[lower.tri(euro)]],V2=colnames(euro)[col(euro)[lower.tri(euro)]],V3=euro[lower.tri(euro)])
> lower
         V1        V2   V3
1 Barcelona    Athens 3313
2  Brussels    Athens 2963
3  Brussels Barcelona 1318
> n=unique(c(lower[,1],lower[,2]))
> full=rbind(lower,setNames(lower[,c(2,1,3)],names(lower)),data.frame(V1=n,V2=n,V3=0))
> full
         V1        V2   V3
1 Barcelona    Athens 3313
2  Brussels    Athens 2963
3  Brussels Barcelona 1318
4    Athens Barcelona 3313
5    Athens  Brussels 2963
6 Barcelona  Brussels 1318
7    Athens    Athens    0
8 Barcelona Barcelona    0
9  Brussels  Brussels    0
> l2w(full,sort=T)
          Athens Barcelona Brussels
Athens         0      3313     2963
Barcelona   3313         0     1318
Brussels    2963      1318        0

Or here's another approach:

> rc=as.matrix(lower[-3])
> n=sort(unique(c(rc)))
> m=matrix(0,length(n),length(n),,list(n,n))
> m[rc]=lower[,3]
> m[rc[,2:1]]=lower[,3]
> m
          Athens Barcelona Brussels
Athens         0      3313     2963
Barcelona   3313         0     1318
Brussels    2963      1318        0

Another simple method in base R is to use xtabs. The result of xtabs is basically just a matrix with a fancy class name, but you can make it look like a regular matrix with class(x)=NULL;attr(x,"call")=NULL;dimnames(x)=unname(dimnames(x)):

> x=xtabs(value~name+numbers,dat1);x
            numbers
name                  1          2          3          4
  firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
  secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357
> str(x)
 'xtabs' num [1:2, 1:4] 0.341 -0.898 -0.703 -0.335 -0.38 ...
 - attr(*, "dimnames")=List of 2
  ..$ name   : chr [1:2] "firstName" "secondName"
  ..$ numbers: chr [1:4] "1" "2" "3" "4"
 - attr(*, "call")= language xtabs(formula = value ~ name + numbers, data = dat1)
> class(x)
[1] "xtabs" "table"
> class(as.matrix(x)) # `as.matrix` has no effect because `x` is already a matrix
[1] "xtabs" "table"
> class(x)=NULL;class(x)
[1] "matrix" "array"
> attr(x,"call")=NULL;dimnames(x)=unname(dimnames(x))
> x # now it looks like a regular matrix
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357
> str(x)
 num [1:2, 1:4] 0.341 -0.898 -0.703 -0.335 -0.38 ...
 - attr(*, "dimnames")=List of 2
  ..$ : chr [1:2] "firstName" "secondName"
  ..$ : chr [1:4] "1" "2" "3" "4"

Normally as.data.frame(x) converts the result of xtabs back to long format, but you can avoid it with class(x)=NULL:

> x=xtabs(value~name+numbers,dat1);as.data.frame(x)
        name numbers       Freq
1  firstName       1  0.3407997
2 secondName       1 -0.8981073
3  firstName       2 -0.7033403
4 secondName       2 -0.3347941
5  firstName       3 -0.3795377
6 secondName       3 -0.5013782
7  firstName       4 -0.7460474
8 secondName       4 -0.1745357
> class(x)=NULL;as.data.frame(x)
                    1          2          3          4
firstName   0.3407997 -0.7033403 -0.3795377 -0.7460474
secondName -0.8981073 -0.3347941 -0.5013782 -0.1745357

This converts data in wide fromat to long format (unlist converts a dataframe to a vector and c converts a matrix to a vector):

w2l=function(x)data.frame(V1=rownames(x)[row(x)],V2=colnames(x)[col(x)],V3=unname(c(unlist(x))))

如何将数据重新设计为长格式

朱染 2025-02-18 05:32:09

不幸的是,不可能完全隐藏您的软件包实现。您可以(并且应该)使用WebPack创建捆绑包并缩小导出的代码。这样,对于某人来说,很难对您的代码进行逆向工程,但这仍然是可行的。

由于JavaScript未编译为二进制文件,因此代码的可执行文件将始终为JavaScript,因此可以进行反向设计。

Unfortunately it is impossible to completely hide your package implementation. What you can (and should) do is using Webpack to create a bundle and minify your exported code. With that, it is pretty hard for someone to reverse engineer your code, but it is still doable.

Since Javascript is not compiled to binary, the executable of your code will always be Javascript, therefore it could be reverse engineered.

使Nest.js项目可执行,但没有源代码

朱染 2025-02-18 01:46:09

假设所有项目都具有“ plost_status” 键,则可以尝试使用此操作。

[键的键,obj.items()中的值

Assuming all items has "following_status" key, you can try this.

[key for key, value in obj.items() if value["following_status"] == "followed"]

匹配JSON的值后获取钥匙

朱染 2025-02-17 19:39:07

React Native主要在 ios Android 上使用,但是如果要在Web上使用此应用程序,则可以使用

React Native mostly use on ios and android but if you want to use this application on web you can encrypt those data using Crypto so you encrypt your data before you store them.

反应:Securestore在移动设备上工作。如何在Web浏览器上确保JWT安全?

朱染 2025-02-17 05:43:22

我猜这只是我是个菜鸟。在Word Press的设置中,我将网站地址更改为IP,但没有将WordPress URL更改为IP。一旦我做到了这一切,现在一切都很好。

This is just me being a noob I guess. In the settings of word press I changed the site address to my ip, but not my wordpress url. Once I did that it all works great now.

刚刚在NGINX上安装了WordPress网站,我可以在本地看到图像,但不能在线?

朱染 2025-02-17 00:43:16

好的,我找到了答案。我将把这个问题放置在适当的情况下,以防其他人偶然发现同一问题:

实际上,问题的代码是正确的, 添加本地会议。但是,翻译器 不会从会话中加载语言环境,而是从当前请求加载。因此,该语言环境的存储正确但不使用...

解决此问题,必须添加一个请求侦听器,该请求侦听器检查会话的语言环境并将其添加到请求中。这在

Ok, I found the answer. I will leave the question in place in case someone else stumbles over the same problem:

In fact the code from the question is correct and does add the local to the session. However, the translator does NOT load the locale from the session but from the current request. So the locale is stored correctly but not used...

To solve this, one has to add a request listener which checks the session for a locale and add it to the request. This is described in the docs linked in the question. I got this wrong and though one has to implement one OR the other when in fact both listeners are needed.

如何在Symfony 6的用户会话中制作用户语言环境?

更多

推荐作者

櫻之舞

文章 0 评论 0

弥枳

文章 0 评论 0

m2429

文章 0 评论 0

野却迷人

文章 0 评论 0

我怀念的。

文章 0 评论 0

更多

友情链接

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文