小编use*_*388的帖子

ForeignKeyAttribute on属性无效

我已经阅读过如何在MVC3中使用Code First Entity Framework(4.1)声明外键关系?但我无法接到我的号召,不会产生任何结果.它有以下错误:

类型为"MyBlog.Tbl_Footer_Item"的属性"Footer_Item_Header_ID"上的ForeignKeyAttribute无效.在依赖类型"MyBlog.Tbl_Footer_Item"上找不到导航属性"Tbl_Footer_Header".Name值应该是有效的导航属性名称.

在这一行:

Dim footerNavElements = db.Tbl_Footer_Headers.Where(Function(i) i.Footer_Header_Order = 1).Single.Items
Run Code Online (Sandbox Code Playgroud)

这是我的父模型:

Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations

Public Class Tbl_Footer_Header

    <Key()> Public Property Footer_Header_ID() As Integer
    Public Property Footer_Header_Content() As String
    Public Property Footer_Header_Order() As Integer

    Public Overridable Property Items As ICollection(Of Tbl_Footer_Item)

End Class

Public Class FooterHeaderDbContext
    Inherits DbContext

    Public Property Tbl_Footer_Headers As DbSet(Of Tbl_Footer_Header)

End Class
Run Code Online (Sandbox Code Playgroud)

这是我的孩子模特:

Imports System.Data.Entity
Imports System.ComponentModel.DataAnnotations

Public Class Tbl_Footer_Item

    <Key()> Public Property Footer_Item_ID() As Integer
    <ForeignKey("Tbl_Footer_Header")>
    Public Property Footer_Item_Header_ID() As …
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net-mvc entity-framework asp.net-mvc-3

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

jQuery,无法获得textbox的价值

在我的代码中,我可以获取对象而不是值.如何获取.cups文本框的值?谢谢.

HTML:

<tr id="20">

      <td class="description">CHEESE,FONTINA</td>
      <td><input type="text" class="cups" value=""></td>
      <td><input type="checkbox" class="breakfast"></td>
      <td><input type="checkbox" class="lunch"></td>
      <td><input type="checkbox" class="dinner"></td>
      <td><input type="checkbox" class="snack"></td>
      <td><input type="checkbox" class="favorites"></td>
      <td><label class="addFood"><input type="button" class="input_text_custom input_button" value="Add"></label></td>

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

JS:

$(document).ready(function () {

    $('.addFood').click(function () {

        var tr = $(this).parents('tr');

        var foodId = tr.attr('id');  // works
        var servings = tr.children('.cups');  // returns [object Object]
        var servings = tr.children('.cups').val();  // returns undefined
        alert(servings);

    });

});
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

无法在C#中连接到SalesForce

我正在关注本教程http://wiki.developerforce.com/page/Integrating_Force.com_with_Microsoft_.NET

但是,我收到此错误:

LOGIN_MUST_USE_SECURITY_TOKEN:用户名,密码,安全令牌无效; 或用户被锁定.你在新的位置吗?从公司的可信网络外部访问Salesforce(通过桌面客户端或API)时,必须在密码中添加安全令牌才能登录.要接收新的安全令牌,请登录salesforce.com,http://login.salesforce.com并单击"设置"| 我的个人信息| 重置安全令牌.

这是我的控制台应用程序中的代码:

static void Main(string[] args)
        {
            string userName;
            string password;
            userName = "me@myWebsite.com";
            password = "myPassword";

            SforceService SfdcBinding = null;
            LoginResult CurrentLoginResult = null;
            SfdcBinding = new SforceService();
            try
            {
                CurrentLoginResult = SfdcBinding.login(userName, password);
            }
            catch (System.Web.Services.Protocols.SoapException e)
            {
                // This is likley to be caused by bad username or password
                SfdcBinding = null;
                throw (e);
            }
            catch (Exception e)
            {
                // This is something else, probably comminication
                SfdcBinding = null; …
Run Code Online (Sandbox Code Playgroud)

c# api salesforce salesforce-service-cloud

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

TaskbarItemInfo.ProgressValue未更新

如屏幕截图所示,我的ProgressBar1.Value更新正常,但不是我的TaskbarItemInfo.ProgressValue:

在此输入图像描述

这是我用来更新两者的代码:

void bw_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    // Set the Value porperty when progress changed.
    this.ProgressBar1.Value = (double)e.ProgressPercentage;

    this.TaskbarItemInfo.ProgressState = TaskbarItemProgressState.Normal;
    this.TaskbarItemInfo.ProgressValue = e.ProgressPercentage / 100;
}
Run Code Online (Sandbox Code Playgroud)

如何TaskbarItemInfo正确进行更新?

c# wpf taskbar

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

通过LINQ获取字符串列表

我想在下面的代码中获取一个字符串列表的列表,我得到的select是:

无法将类型'System.Data.EnumerableRowCollection>'隐式转换为'System.Collections.Generic.List>'

List<List<string>> rows = (from myRow in data.AsEnumerable()
                            select new List<string> {myRow["FirstName"].ToString(),
                                myRow["LastName"].ToString(),
                                myRow["Department"].ToString(),
                                myRow["Birthdate"].ToString(),
                                myRow["Description"].ToString()
                            });
Run Code Online (Sandbox Code Playgroud)

如何获取字符串列表?

c# linq

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

导入scikit-learn时出错

我正在尝试使用以下代码:

from matplotlib import pyplot as plt
from sklearn.datasets import load_iris
import numpy as np
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

ImportError: No module named sklearn.datasets
Run Code Online (Sandbox Code Playgroud)

然后我尝试安装scikit-learn,但得到这些错误:

pip install -U scikit-learn
  File "<ipython-input-9-6d283b29f0f9>", line 1
    pip install -U scikit-learn
              ^
SyntaxError: invalid syntax


easy_install -U scikit-learn
  File "<ipython-input-10-59440c1e5ef6>", line 1
    easy_install -U scikit-learn
                         ^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)

我正在使用Enthought Canopy Expresss,我认为"The Enthought Python Distribution已经发布了最新版本." 根据http://scikit-learn.org/stable/install.html#enthought-python-distribution

我该怎么用scikit-learn

编辑:

pip通过easy_install pip我安装然后尝试运行pip install -U scikit-learn,我得到这些错误(从我的日志文件):

running build_clib

No module …
Run Code Online (Sandbox Code Playgroud)

python pip scikit-learn canopy

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

TCPDF 页面大小更改是创建多个页面,而我只想要一个页面

正如你在我的代码中看到的;我只是想创建一个 4 英寸宽、3 英寸高的 PDF 文档。

// create new PDF document
$pagelayout = array(3, 4); //  or array($height, $width) 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, 'in', $pagelayout, true, 'UTF-8', false);
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时,我的 PDF 会呈现重复的页面(完整代码如下):

在此输入图像描述

我想要实现的是:

在此输入图像描述

如何让 TCPDF 仅创建一张 4" x 3" 图像,就像我上面所做的那样?

这是我的 TCPDF 的完整代码:

<?php

// Include the main TCPDF library (search for installation path).
require_once('../library/tcpdf/config/tcpdf_config.php');
require_once('../library/tcpdf/tcpdf.php');

// create new PDF document
$pagelayout = array(3, 4); //  or array($height, $width) 
$pdf = new TCPDF(PDF_PAGE_ORIENTATION, 'in', $pagelayout, true, 'UTF-8', false);

/*
// set …
Run Code Online (Sandbox Code Playgroud)

php pdf pdf-generation tcpdf

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

无法为订购LINQ查询创建Func表达式

我从我的请求中收到此参数:

sort=homeCountry
Run Code Online (Sandbox Code Playgroud)

我需要按照发送到sort参数的任何列进行排序,因此我创建了一个类似的方法:

string sort = "homeCountry";
Func<PaymentRateTrip, string> orderBy = (
    x => sort == "homeCountry" ? x.HomeCountry :
        sort == "hostCountry" ? x.HostCountry :
            sort == "homeLocation" ? x.HomeLocation :
                sort == "hostLocation" ? x.HostLocation :
                    x.HomeLocation
);
Run Code Online (Sandbox Code Playgroud)

这工作正常.

但是,上面的列都是字符串.但是,我还需要添加十进制列,如下所示:

string sort = "homeCountry";
Func<PaymentRateTrip, string> orderBy = (
    x => sort == "homeCountry" ? x.HomeCountry :
        sort == "hostCountry" ? x.HostCountry :
            sort == "homeLocation" ? x.HomeLocation :
                sort == "hostLocation" ? x.HostLocation :
                    sort …
Run Code Online (Sandbox Code Playgroud)

c# linq func

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

团队如何在VB ASP.NET MVC站点上工作?

在PHP中,您只需登录FTP并查看所有文件即可.我在VB ASP.NET MVC中注意到,当我发布一个站点时,它不包含控制器或模型.相反,它似乎将它们编译成DLL.如何通过访问原件来修改文件?开发人员是否必须在单独的目录中发布文件,然后其他开发人员将它们拉下来并在visual studio中打开项目?

vb.net asp.net-mvc asp.net-mvc-3

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

没有ClickEvent的定义?

在下面的代码中,我正在尝试为我的按钮模拟Click事件Browse.

private void TextBox_MouseDown(object sender, RoutedEventArgs e)
{
    this.Browse.RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
}
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

'System.Windows.Forms.ButtonBase'不包含'ClickEvent'的定义

如何举起点击事件?

似乎有些人质疑这段代码的目的.我在这里得到它/sf/answers/51378211/,我只是想让它工作.

c# wpf

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

使用 PaperJs 动画绘制线条

这是我的代码:

<!DOCTYPE html>
<html>
<head>
<!-- Load the Paper.js library -->
<script type="text/javascript" src="paper.js"></script>
<!-- Define inlined PaperScript associate it with myCanvas -->
<script type="text/paperscript" canvas="myCanvas">

    // Create a Paper.js Path to draw a line into it:
    var path = new Path();
    // Give the stroke a color
    path.strokeColor = 'black';
    var start = new Point(100, 100);
    // Move to start and draw a line from there
    path.moveTo(start);
    // Note the plus operator on Point objects.
    // PaperScript does that …
Run Code Online (Sandbox Code Playgroud)

javascript html5-canvas paperjs

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

LINQ不读括号

这是我的LINQ(EF):

var ls = from ps in ctx.Package_Services
     where 
        (ps.Package.Policy.Name != "Short-Term Career Policy"
            && ps.Package.Name != "Early Talent Package")
        &&
        (ps.Package.Policy.Name != "Assignment Policy"
            && ps.Package.Name != "Efficient Package")
     select new
     {
         Service = ps.Service,
         PackageService = ps
     };
Run Code Online (Sandbox Code Playgroud)

这是它生成的相关SQL:

WHERE (N'Early Talent Package' <> [Extent2].[Name]) 
AND (N'Efficient Package' <> [Extent2].[Name]) 
AND (N'Short-Term Career Policy' <> [Extent3].[Name]) 
AND (N'Assignment Policy' <> [Extent4].[Name])
Run Code Online (Sandbox Code Playgroud)

我想说的是,"我不想要组合X,我也不想要组合Y;但是,我确实想要"早期人才套餐",它们与"短期职业政策"无关. "而且,当他们与"作业政策"无关时,我也想要"高效套餐".

如何将其转换为LINQ?

c# sql linq entity-framework

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

异步返回对象列表

我试图循环结果集,运行查询以检索数据,然后将该数据添加到列表并返回它.

问题是,我试图异步这样做,我收到错误:

'System.Collections.Generic.List'不包含'ToListAsync'的定义,并且最好的扩展方法重载'System.Data.Entity.QueryableExtensions.ToListAsync(System.Linq.IQueryable)'有一些无效的参数

以下是该方法的代码:

public async Task<List<IHFData>> GetHFServiceData(string wtTransfereeId)
{
    var hfDataList = new List<HFData>();

    Parallel.ForEach(aauthorizationList, item =>
    {
        // code to retrieve data from database (truncated)
        HFData hfData = Db.hfAuthorizations.AsNoTracking()....SingleOrDefault();

        hfDataList.Add(hfData);
    }

    return await hfDataList.ToListAsync(); // errors on this line
}
Run Code Online (Sandbox Code Playgroud)

如何异步构建和返回我的列表?

c# linq asynchronous

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