小编Wib*_*wan的帖子

Xamarin Android 使用 GetExternalFilesDir() 获取 privateExternalStorage

我有一个应用程序需要在特定于应用程序的目录中创建一个文件,但该文件需要是公共的,以便可以由另一个应用程序编辑,所以我需要这样的路径"/storage/emulated/0/Android/data/com.my.app/files"

我已经检查了Xamarin 文档并找到了我需要的内容。基于该文档我可以使用这种方法Android.Content.Context.GetExternalFilesDir(string type)

但是当我调用该方法时出现此错误。

An object reference is required for the non-static field, method, or property 'Context.GetExternalFilesDir(string)'

我也已经检查过这个论坛,但没有找到运气

有什么想法如何解决这个问题吗?

android xamarin.android xamarin

3
推荐指数
1
解决办法
3046
查看次数

GORM 选择具有预加载的特定列

假设我有这些代表我的模型的结构

type QuestionHeader struct {
  QuestionHeaderId int    `gorm:"primaryKey;column:question_id" json:"question_id"`
  LevelId          int    `gorm:"column:level_id" json:"level_id"`
  SubjectId        int    `gorm:"column:subject_id" json:"subject_id"`
  QuestionBody     []QuestionBody
  QuestionSolution []QuestionSolution
  OtherColumn1A    string
  OtherColumn2A    string
}


type QuestionBody struct {
  QuestionBody  int    `gorm:"primaryKey;column:question_id" json:"question_id"`
  Value         string `gorm:"column:value" json:"value"`
  Type          string `gorm:"column:type" json:"type"`
  OtherColumn1B string
  OtherColumn2B string
}

type QuestionSolution struct {
  QuestionSolutionId int    `gorm:"primaryKey;column:question_id" json:"question_id"`
  Value              string `gorm:"column:value" json:"value"`
  Type               string `gorm:"column:type" json:"type"`
  OtherColumn1C      string
  OtherColumn2c      string
}
Run Code Online (Sandbox Code Playgroud)

然后我想像这样进行预加载查询

qs.db().
  Preload("QuestionHeader.QuestionBody", func(db *gorm.DB) *gorm.DB {
      return db.Where("question_body.status = ?", 1) …
Run Code Online (Sandbox Code Playgroud)

go go-gorm

1
推荐指数
1
解决办法
4980
查看次数

标签 统计

android ×1

go ×1

go-gorm ×1

xamarin ×1

xamarin.android ×1