小编Tom*_*van的帖子

Entity Framework Core:扩展实体而无需部分

我必须扩展当前的数据库实体 ( Foo) 以包含新字段。听起来很容易,但我很难找到解决方案。问题是,我无法为其创建分部类,Foo因为它是我正在使用的 dll 的一部分。我无法Foo按照我的意愿请求修改(或由我自己完成)。

我的项目结构与此类似:

// unmodifiable because part of dll
class Foo 
{
    int Id { get; set; }
    string Name { get; set; }
}

// unmodifiable because part of dll
interface IFooContext 
{
     DbSet<Foo> Foo { get; set; }
}

class FooContext: DbContext, IFooContext 
{
     DbSet<Foo> Foo { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

由于我对 .net 的了解有限,我尝试创建Bar扩展的类,并期望使用扩展类Foo来实现它就足够了。IFooContextBar

您可以在下面看到,但最终会出现错误,因为 C# 不允许使用可与父级互换的扩展类。

class Bar: Foo 
{
     string Description …
Run Code Online (Sandbox Code Playgroud)

.net c# entity-framework entity-framework-core .net-core

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

找不到 Gradle DSL 方法:'versionCode()'

在构建我的 Android 项目时遇到问题。我使用Grgit来填充versionCodeversionName在 gradle 中。一切正常,直到我将 Android Studio 和 gradle 工具更新到更新版本(构建 3.4.0 和发行版 5.1.1)。

./gradlew build 失败并显示错误:

* What went wrong:
A problem occurred evaluating project ':app'.
> Could not find method versionCode() for arguments [1555447320] on ProductFlavor_Decorated{name=dev, dimension=null, minSdkVersion=null, targetSdkVersion=null, renderscriptTargetApi=null, renderscriptSupportModeEnabled=null, renderscriptSupportModeBlasEnabled=null
, renderscriptNdkModeEnabled=null, versionCode=null, versionName=null, applicationId=null, testApplicationId=null, testInstrumentationRunner=null, testInstrumentationRunnerArguments={}, testHandleProfiling=null, testFunctionalTest=null, signingConfig=null, resConfi
g=null, mBuildConfigFields={}, mResValues={}, mProguardFiles=[], mConsumerProguardFiles=[], mManifestPlaceholders={}, mWearAppUnbundled=null} of type com.android.build.gradle.internal.dsl.ProductFlavor.
Run Code Online (Sandbox Code Playgroud)

提供外部的脚本 ( project/tools/script-git-version.gradle)

buildscript {
    repositories {
        jcenter() …
Run Code Online (Sandbox Code Playgroud)

git android build gradle grgit

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