我试图在EF7中设置模型的关系,但我遇到了问题:OnModelCreating方法并且DbModelBuilder未定义.
过去,我使用EF6,但现在我尝试迁移到EF7.
这是我的代码
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
//Section -> many Category
modelBuilder.Entity<Section>()
.HasMany<Category>(p => p.Categories)
.WithRequired(p => p.Section);
//Section -> many PriceCategory
modelBuilder.Entity<Section>()
.HasMany<PriceCategory>(p => p.PriceCategories)
.WithRequired(p => p.Section);
//Category - many Procedures
modelBuilder.Entity<Category>()
.HasMany<Procedure>(p => p.Procedures)
.WithRequired(p => p.Category);
//PriceCategory - many PriceProcedures
modelBuilder.Entity<PriceCategory>()
.HasMany<PriceProcedure>(p => p.PriceProcedures)
.WithRequired(p => p.PriceCategory);
}
Run Code Online (Sandbox Code Playgroud)
我的进口:
using Microsoft.Data.Entity;
using Domain.Models;
Run Code Online (Sandbox Code Playgroud)
我的project.json:
{
"version": "1.0.0-*",
"description": "Domain Class Library",
"authors": [ "Garrus" ],
"tags": [ "" ],
"projectUrl": …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用提交验证进行表单.当我提交表格时,我handleSubmit被解雇并抛出SubmissionError,但没有任何事情发生.
提交(每次只抛出错误):
function submit(values)
{
console.log(values);
throw new SubmissionError({ password: 'Wrong password', _error: 'Login failed!' });
}
Run Code Online (Sandbox Code Playgroud)
从示例中渲染字段:
const renderField = ({ input, label, type, meta: { touched, error } }) => (
<div>
<label>{label}</label>
<div>
<input {...input} placeholder={label} type={type}/>
{touched && error && <span>{error}</span>}
</div>
</div>
)
Run Code Online (Sandbox Code Playgroud)
我的表格:
class LoginForm extends Component {
render()
{
const { error, handleSubmit, pristine, reset, submitting } = this.props
console.log(error);
return (
<div>
<form onSubmit={handleSubmit}>
<h1>Login</h1>
<Field name="email" type="text" …Run Code Online (Sandbox Code Playgroud) 我在ASP.NET 5(CoreCLR)上有一个应用程序,我尝试将其发布到Microsoft Azure.我使用免费Web App(不是VDS)
我正在使用Visual Studio 2015发布应用程序Publish->Microsoft Azure并遵循此说明.
但是当我发布它并尝试打开时,我看到只是不间断加载空页面.我启用日志记录并从Azure查看日志(stdout.log),并且只有:
'"dnx.exe"' is not recognized as an internal or external command,
Run Code Online (Sandbox Code Playgroud)
可操作程序或批处理文件.
我还试着Continiusly publishing用git 做.在推送期间,它开始恢复包并因错误而失败no disk space available.
有没有办法将ASP.NET 5应用程序发布到Azure Web App?
我正在设计我的应用程序并想要设置按钮背景颜色并保持它们像材料一样.
设置按钮背景颜色
我为按钮创建样式,设置colorPrimary和设置按钮样式和colorButtonNormal.它有效.
style name="AppTheme.Button" parent="Widget.AppCompat.Button.Colored">
<item name="android:textColor">@android:color/white</item>
<item name="colorButtonNormal">@color/colorAccent</item>
</style>
...
<item name="android:buttonStyle">@style/AppTheme.Button</item>
<item name="colorButtonNormal">@color/colorAccent</item>
Run Code Online (Sandbox Code Playgroud)
但我想做一个不同颜色的按钮.我尝试使用backgroundTint,但它不起作用.所以我创造风格:
<style name="AppTheme.Button.Wildberries" parent="Widget.AppCompat.Button.Colored">
<item name="colorButtonNormal">@color/wildberries</item>
</style>
Run Code Online (Sandbox Code Playgroud)
它适用于Android 4.x,但在Android 5.x按钮仍然是colorAccent.
我为按钮创建了style-v21:
<style name="AppTheme.Button.Wildberries" parent="@android:style/Widget.Material.Button">
<item name="android:backgroundTint">@color/wildberries</item>
</style>
Run Code Online (Sandbox Code Playgroud)
适用于Android Studio:
适用于Android 4.x
但不适用于5.x.
我也尝试使用AppCompat.Button:
<android.support.v7.widget.AppCompatButton
xmlns:app="http://schemas.android.com/apk/res-auto"
app:backgroundTint="@color/wildberries"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="??????? ?? ????"
android:id="@+id/WildBtn"
android:textSize="14dp"
android:textColor="@android:color/white"
android:theme="@style/AppTheme.Button.Wildberries"
android:stateListAnimator="@null" />
Run Code Online (Sandbox Code Playgroud)
一无所获:
在Android 4.x设备按钮仍为紫色,5.x仍为绿色.
那么,在android 4.x和hihger上设置按钮背景颜色的方法是什么?
我正在尝试将我的ASP.NET 5 MVC项目部署到本地IIS,但面临一些错误.
当打开(我的网站地址)localhost:80我有HTTP 404.如果我manualy运行,我面临相同的行为approot\web.cmd.我认为问题是一样的.在web.cmd控制台中,我看到每个请求的输出(对于非静态路由,静态文件很好):
fail: Microsoft.Data.Entity.Query.Internal.SqlServerQueryCompilationContextFactory[1]
An exception occurred in the database while iterating the results of a query.
System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. File not found.
File name: 'System.Data.SqlClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.IO.FileNotFoundException: Could not load the specified file.
File name: 'System.Data.SqlClient'
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyName(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.Data.Entity.Storage.Internal.SqlServerConnection.CreateDbConnection()
at Microsoft.Data.Entity.Internal.LazyRef`1.get_Value()
at Microsoft.Data.Entity.Storage.RelationalConnection.Open()
at Microsoft.Data.Entity.Query.Internal.QueryingEnumerable.Enumerator.MoveNext()
at …Run Code Online (Sandbox Code Playgroud) 如何为adnroid应用程序中的所有活动设置背景并保持其纵横比?
我正在使用android:windowBackground风格,但我不知道如何保持背景图像的纵横比。
是否只有ImageView手动为所有活动添加背景的方法?
我正在使用Android Studio模板中的导航抽屉.我想在我的一些片段中使用UP按钮(箭头)插入"汉堡"按钮.我用AppCompatActivity.
我使用此代码显示UP按钮箭头:
public void UseUpButton(boolean value) {
ActionBar actionBar = getSupportActionBar();
if (value) {
actionBar.setDisplayHomeAsUpEnabled(false);
toggle.setDrawerIndicatorEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(true);
} else {
toggle.setDrawerIndicatorEnabled(true);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我无法点击这个按钮.我试过一些方法:
onOptionsItemSelectedpublic boolean onOptionsItemSelected(MenuItem item) {
Log.d("WTF", "menu");
switch (item.getItemId())
{
case android.R.id.home:
getFragmentManager().popBackStack();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Run Code Online (Sandbox Code Playgroud)
我添加getSupportActionBar().setHomeButtonEnabled(true);到我的Activity::onCreate,但是onOptionsItemSelected当我按下向上按钮时没有调用,当我按下菜单项时它正常工作.
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open,
R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle); …Run Code Online (Sandbox Code Playgroud) android android-fragments android-actionbar up-button navigation-drawer
我无法理解很多ASP.NET Core框架名称之间的区别: - dnxcore50 - dotnet5.4 - netcoreapp
dotnet5.4是一个新名称dnxcore50?
我创建类库项目,并有dotent5.4在project.json.然后我创建一个空的ASP.NET项目dnxcore50.
我将依赖项添加Microsoft.EntityFrameworkCore 1.0.0到项目并获取错误:
The dependency Microsoft.EntityFrameworkCore does not support for framework NETPlatform, Version=v5.4
什么是正确的框架版本和实体框架版本?
c# asp.net entity-framework entity-framework-core asp.net-core
我需要具有固定高度(例如 200)和背景图像的AspectFill块,该块应该是该块并且该块StackLayout底部的高度未知。
我试图用RelativeLayout,并把Image与StackLayout它。图片放置完美,但我不知道如何放置StackLayout在底部。
此布局包含两个Labels,因此我无法对其进行硬编码HeightConstrait并YConstrait保持不变,因为它的文本在不同平台和屏幕尺寸上可能具有不同的高度(或者,这可能是错误的?)
我怎样才能做到这一点?
我正在使用 Kotlin 并尝试使用新的数据绑定库,但我遇到了未解决的xxxBinding类引用错误。
顶层 build.gradle
buildscript {
ext.kotlin_version = '1.2.30'
ext.gradle_version = '3.1.0'
repositories {
google()
jcenter()
}
dependencies {
classpath "com.android.tools.build:gradle:$gradle_version"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)
应用程序 build.gradle
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.google.gms.google-services' …Run Code Online (Sandbox Code Playgroud) 我添加angular2-datable库,但是在加载库文件时我得到404 Not Found,例如:
我解决我systemjs.config.js喜欢这个答案,但它仍然没有工作:
map: {
...
'lodash': 'npm:lodash/lodash.js',
'angular2-datatable':'npm:angular2-datatable/index.js'
},
packages: {
...
'lodash': {
defaultExtension: 'js'
},
'angular2-datatable': {
defaultExtension: 'js'
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试设计我的应用程序并制作自己的主题,但我遇到了一些问题,因为我需要一些不寻常的行为。
我与父母一起使用 Material Design 主题 Theme.AppCompat.Light.DarkActionBar
视图有颜色:
textColorPrimary, textColorSecondary,textColorTertiarytextColorPrimary(?)textColorSecondarycolorAccent但是我需要
accentColor背景和白色文本textColorPrimary, textColorSecondary, textColorTertiary) 都是深绿色的变体所以,我创造风格 Button.Default
<style name="Button.Default" parent="Widget.AppCompat.Button">
<item name="colorButtonNormal">@color/colorAccent</item>
<item name="android:textColor">@android:color/white</item>
</style>
Run Code Online (Sandbox Code Playgroud)
并在我的主题中使用它:
<item name="android:buttonStyle">@style/Button.Default</item>
Run Code Online (Sandbox Code Playgroud)
好的,颜色改变了,但背景没有。我将此行添加到主题样式:
<item name="colorButtonNormal">@color/colorFakeAccent</item>
Run Code Online (Sandbox Code Playgroud)
好的
<style name="Checkbox.Default" parent="Widget.AppCompat.CompoundButton.CheckBox">
<item name="android:textColor">@color/colorPrimary</item>
<item name="colorAccent">@color/colorPrimary</item>
</style>
Run Code Online (Sandbox Code Playgroud)
复选框样式没有改变。如何设置复选框、单选按钮未选中和选中颜色?
我想在EF中创建一对一关系,其中外键可以为null(因此,它可以被称为0..1到0..1)
public class ProductInstance
{
public int Id { get; set; }
public int SaleId { get; set; }
public Sale Sale { get; set; }
}
public class Sale
{
public int Id { get; set; }
public ProductInstance ProductInstance { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
FluentAPI 组态:
modelBuilder.Entity<Sale>()
.HasOptional(x => x.ProductInstance)
.WithOptionalPrincipal(x => x.Sale);
Run Code Online (Sandbox Code Playgroud)
但它在表中生成两列ProductInstance:
Sale_id - 外键SaleId这是生成的迁移代码:
CreateTable(
"dbo.ProductInstances",
c => new
{
Id = c.Int(nullable: false, identity: true),
SaleId = c.Int(nullable: false),
Sale_Id …Run Code Online (Sandbox Code Playgroud) android ×6
asp.net-core ×4
c# ×4
asp.net ×3
angular ×1
azure ×1
iis ×1
javascript ×1
kotlin ×1
one-to-one ×1
reactjs ×1
redux ×1
redux-form ×1
typescript ×1
up-button ×1
xamarin ×1
xaml ×1