小编ami*_*133的帖子

约束布局中的布局权重

我对约束布局概念很陌生。我想创建一个连续 3 个视图的布局。第 2 个视图应显示没有任何重量,第 3 个视图应占据屏幕的第二半部分。基本上我想将下面的代码隐藏到约束布局。此外,当第三个视图可见性消失时,剩下的两个视图应该占据所有宽度。

  <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent"
        android:layout_weight="1">

        <Button
            android:id="@+id/b1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="he" />

        <Button
            android:id="@+id/b4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="he" />



    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimaryDark"
        android:layout_weight="1">


        <Button
            android:id="@+id/b3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="hello2" />

    </LinearLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

我在下面添加了屏幕截图:

图像

android android-constraintlayout

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

EFcore中的'FromSql'操作的结果中不存在所需的列'id'

我有一个主要问题FromSql,就是这样:

我有一个这样的模型:

public partial class  model
{
    public string name
}
Run Code Online (Sandbox Code Playgroud)

我想从数据库中的过程中获取一些结果(sql serever)。当我执行以下代码

var sql = "EXECUTE [myprocedure] @param1 ";
SqlParameter sqlParameter = new SqlParameter
{
     ParameterName = "param1",
     DbType = DbType.Int32,
     Value = 10;
}
var result = db.model.FromSql(sql,SqlParameter);
Run Code Online (Sandbox Code Playgroud)

它显示了这样一个例子: The entity type 'model' requires a primary key to be defined. 所以我在模型中添加了主键:

public partial class  model
{
    [key]
    public int ID {set;get;}

    public string name
}
Run Code Online (Sandbox Code Playgroud)

但这次它显示了此执行:The required column 'ID' was not present in the results …

c# linq sql-server entity-framework entity-framework-core

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