小编net*_*jor的帖子

LINQ to Entities中仅支持无参数构造函数和初始值设定项

我在这个linq表达式中有这个错误:

var naleznosci = (from nalTmp in db.Naleznosci
                              where nalTmp.idDziecko == idDziec
                              select new Payments
                              (
                                  nalTmp.Dziecko.Imie,
                                  nalTmp.Dziecko.Nazwisko,
                                  nalTmp.Miesiace.Nazwa,
                                  nalTmp.Kwota,
                                  nalTmp.RodzajeOplat.NazwaRodzajuOplaty,
                                  nalTmp.RodzajeOplat.TypyOplat.NazwaTypuOplaty,
                                  nalTmp.DataRozliczenia,
                                  nalTmp.TerminPlatnosci
                              )).ToList();
Run Code Online (Sandbox Code Playgroud)

任何想法如何解决这个问题?我尝试任何表达式的组合......:/

c# linq-to-entities

124
推荐指数
6
解决办法
9万
查看次数

通过类的反射属性获取,但不是从继承的类获取

class Parent {
   public string A { get; set; }
}

class Child : Parent {
   public string B { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我只需要获得属性B,没有属性A但是

Child.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)
Run Code Online (Sandbox Code Playgroud)

返回两个属性:/

c# reflection

71
推荐指数
3
解决办法
2万
查看次数

csproj中的错误 - 重复项目

我有Visual Studio 2010的错误:

错误1在"Sources"参数中多次指定"CrossDomainService.svc.cs"项."Sources"参数不支持重复项.WcfServiceDomain

并从msbuild

C:\ Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.CSharp.targets(160,9):错误MSB3105:"Sources"参数中指定的项目"CrossDomainService.svc.cs"超过了oce ."Sources"参数不支持重复项.[C:\ inetpub\Wwwroot\axaptaWcfConnection\WcfServiceDomain\WcfSer viceDomain.csproj]

我的文件是csproj:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>
    </ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{8D40933A-E036-4CD0-9003-314A692724D5}</ProjectGuid>
    <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>WcfServiceDomain</RootNamespace>
    <AssemblyName>WcfServiceDomain</AssemblyName>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    <TargetFrameworkProfile />
    <FileUpgradeFlags>
    </FileUpgradeFlags>
    <UpgradeBackupLocation>
    </UpgradeBackupLocation>
    <OldToolsVersion>4.0</OldToolsVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <PlatformTarget>x86</PlatformTarget>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup> …
Run Code Online (Sandbox Code Playgroud)

msbuild projects-and-solutions visual-studio-2010

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

无法将类型'System.Linq.IQueryable'隐式转换为'System.Collections.Generic.IList'

我有一个方法:

public DzieckoAndOpiekunCollection GetChildAndOpiekunByFirstnameLastname(string firstname, string lastname)
{
    DataTransfer.ChargeInSchoolEntities db = new DataTransfer.ChargeInSchoolEntities();
    DzieckoAndOpiekunCollection result = new DzieckoAndOpiekunCollection();
    if (firstname == null && lastname != null)
    {
        IList<DzieckoAndOpiekun> resultV = from p in db.Dziecko
                      where lastname == p.Nazwisko
                      **select** new DzieckoAndOpiekun(
                     p.Imie,
                     p.Nazwisko,
                     p.Opiekun.Imie,
                     p.Opiekun.Nazwisko)
                  ;
        result.AddRange(resultV);
    }
    return result;
}
Run Code Online (Sandbox Code Playgroud)

和选定位置的错误:

错误1无法将类型'System.Linq.IQueryable <WcfService1.DzieckoAndOpiekun>'隐式转换为'System.Collections.Generic.IList <WcfService1.DzieckoAndOpiekun>'.存在显式转换(您是否错过了演员?)

任何想法如何解决我的问题?

.net c# linq linq-to-entities exception-handling

29
推荐指数
3
解决办法
10万
查看次数

以表值作为参数执行存储过程

我创建自己的表类型

CREATE TYPE [dbo].[ObjectsList] AS TABLE(
[Id] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
   [Id] ASC
)WITH (IGNORE_DUP_KEY = OFF)
)
GO
Run Code Online (Sandbox Code Playgroud)

当我想将此类型作为参数传递时

CREATE PROCEDURE [dbo].[GetData](@DataIds ObjectsList READONLY)
Run Code Online (Sandbox Code Playgroud)

我应该如何在EXEC GetData中传递它?

t-sql

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

如何将枚举值添加到列表中

我有以下枚举:

public enum SymbolWejsciowy
{
     K1 , K2 , K3 , K4 , K5 , K6 , K7 , K8 
}
Run Code Online (Sandbox Code Playgroud)

我想使用此枚举的值创建一个列表:

 public List<SymbolWejsciowy> symbol;
Run Code Online (Sandbox Code Playgroud)

我尝试了几种不同的方法将枚举值添加到列表中:

SymbolWejsciowy symbol;  
symbol.Add(symbol = SymbolWejsciowy.K1); 
Run Code Online (Sandbox Code Playgroud)

symbol.Add(SymbolWejsciowy.K1); 
Run Code Online (Sandbox Code Playgroud)

但是,我总是得到以下异常:

你调用的对象是空的.

我怎样才能正确地完成这个?

c# enums list

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

部分视图呈现按钮单击

我有索引视图:

@using System.Web.Mvc.Html
@model  MsmqTestApp.Models.MsmqData
<!DOCTYPE html>
<html>
<head>
    <script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
    <meta name="viewport" content="width=device-width" />
    <title>MsmqTest</title>
</head>
<body>
    <div>
        <input type="submit" id="btnBuy" value="Buy" onclick="location.href='@Url.Action("BuyItem", "MsmqTest", new { area = "Msmq" })'" />
        <input type="submit" id="btnSell" value="Sell" onclick="location.href='@Url.Action("SellItem", "MsmqTest", new { area = "Msmq" })'" />
    </div>
    <div id="msmqpartial">
    @{Html.RenderPartial("Partial1", Model); }

    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

和部分:

@using System.Web.Mvc.Html
@model  MsmqTestApp.Models.MsmqData

    <p>
        Items to buy
        @foreach (var item in Model.ItemsToBuy)
        { 
            <tr>
                <td>@Html.DisplayFor(model => item)
                </td>
            </tr>
        }
    </p>
    <p>
        <a>Items …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc partial-views

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

用于MBUnit测试的Visual Studio 2008和2010的Gallio测试运行器插件

如果我安装Gallio 3.x还会为Visual Studio安装一个测试运行器插件吗?

或者我是否必须使用其他插件(如TestDriven.NET或Visual Nunit)从VS中运行MbUnit测试类?

mbunit plugins gallio visual-studio

8
推荐指数
2
解决办法
8320
查看次数

从SHA256解密

我有那个代码加密字符串到sha256和base64旁边:

 public static string Sha256encrypt(string phrase)
    {
        UTF8Encoding encoder = new UTF8Encoding();
        SHA256Managed sha256hasher = new SHA256Managed();
        byte[] hashedDataBytes = sha256hasher.ComputeHash(encoder.GetBytes(phrase));
        return Convert.ToBase64String(hashedDataBytes);
    }
Run Code Online (Sandbox Code Playgroud)

如何在另一方解密我的密码?

c# encryption cryptography

8
推荐指数
2
解决办法
4万
查看次数

测试angularjs控制器时 - 无法找到变量:module/inject by chutzpah

我有angularJs控制器

angular.module('App.ctrl.guests', [])
    .controller('guestsController', ['$scope', '$http', '$location', '$timeout', 'guestsService', function ($scope, $http, $location, $timeout, guestsService) {
        $scope.tiles = [];
    }])
Run Code Online (Sandbox Code Playgroud)

和茉莉花测试

/// <reference path="~/Scripts/angular.js" />
/// <reference path="../../ProjectWeb/Scripts/app/guests/guestsCtrl.js" />
/// <reference path="~/Scripts/angular-mocks.js" />
/// <reference path="~/Scripts/jasmine.js" />
'use strict';
describe('App.ctrl.guests', function () {
    var scope, controller;
    beforeEach(function () {
        module('App.ctrl.guests')
    });
    beforeEach(inject(function ($rootScope, $controller) {
        scope = $rootScope.$new();
        controller = $controller('guestsController', {
            $scope: scope
        });
    }));

    it('should have empty array', function () {
        expect(scope.tiles).toBe([]);
    });
})
Run Code Online (Sandbox Code Playgroud)

每次我在Visual studio chutzpah运行时,我得到:

ReferenceError:找不到变量:file …

javascript jasmine chutzpah angularjs visual-studio-2012

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