我在Oracle中使用Entity Framework 4.3代码优先.我收到以下错误:
System.InvalidOperationException:类型为"WidgetDistributor.WidgetEntity"的属性"WidgetSequence"上的ForeignKeyAttribute无效.在依赖类型"WidgetDistributor.WidgetEntity"上找不到外键名称"WIDGETSEQUENCE_ID".Name值应该是以逗号分隔的外键属性名称列表.
我的实体是这样的:
[Table("WIDGETENTITIES")]
public class WidgetEntity {
[Column("WIDGETENTITY_ID")]
public int Id { get; set; }
[ForeignKey("WIDGETSEQUENCE_ID")]
public WidgetSequence Sequence { get; set; }
// and other properties that map correctly
}
[Table("WIDGETSEQUENCES")]
public class WidgetSequence {
[Column("WIDGETSEQUENCE_ID")]
public int Id { get; set; }
[Column("NUMBER")]
public int Number { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的代码似乎正确.我做错了什么,这里?
我试图确定运行时类型是否是某种集合类型.我在下面的工作,但似乎很奇怪,我必须像我所做的那样命名我认为是数组中的集合类型的类型.
在下面的代码中,通用逻辑的原因是因为,在我的应用程序中,我希望所有集合都是通用的.
bool IsCollectionType(Type type)
{
if (!type.GetGenericArguments().Any())
return false;
Type genericTypeDefinition = type.GetGenericTypeDefinition();
var collectionTypes = new[] { typeof(IEnumerable<>), typeof(ICollection<>), typeof(IList<>), typeof(List<>) };
return collectionTypes.Any(x => x.IsAssignableFrom(genericTypeDefinition));
}
Run Code Online (Sandbox Code Playgroud)
我如何重构此代码以使其更智能或更简单?
由于我很确定没有本地html或css方式这样做,我愿意用JavaScript做这件事.显然,我可以在我的div的底部使用overflow:auto在CSS中获得一个滚动条.是否有一些javascript可以从底部"克隆"滚动条并将其放在div的顶部?也许有另一种方式?
我有一个带有Title属性的viewModel .我想使用该属性设置页面标题.这是我尝试过的,但是没有用:
<html>
<head>
<title data-bind="text: Title"></title>
</head>
<body>
<span data-bind="text: Title"/> <!-- this displays the title properly -->
</body>
Run Code Online (Sandbox Code Playgroud)
浏览器标题为空/默认值,而不是我的Title属性值.
我有两个变量:
var trafficLightIsGreen = false;
var someoneIsRunningTheLight = false;
Run Code Online (Sandbox Code Playgroud)
当两个变量符合我的条件时,我想触发一个事件:
if(trafficLightIsGreen && !someoneIsRunningTheLight){
go();
}
Run Code Online (Sandbox Code Playgroud)
假设这两个布尔值在任何时刻都可以改变,那么go()当他们根据我的条件改变时如何触发我的方法呢?
我的思想紧紧围绕着关系数据库,以及如何有效地对其进行编码.我的大部分经验都是使用MySQL和SQL.我喜欢我听说过的基于文档的数据库的许多内容,特别是当最近播客中有人提到巨大的性能优势时.那么,如果我要走这条路,那么从SQL转向NO-SQL必须采取哪些精神步骤?
如果它对你的答案有任何不同,我主要是(现在,无论如何)C#开发人员.我已经习惯了ORM,比如EF和Linq to SQL.在ORM之前,我使用泛型和数据引擎滚动了我自己的对象.也许这很重要,也许不是.
以下是一些更具体的内容:
(随意在这里添加你自己的问题)
我曾经有过几次这样的事情会有所帮助.例如,我有AccountCreator一个Create方法,需要一个NewAccount.我AccountCreator有一个IRepository最终将用于创建帐户.我AccountCreator将首先将属性映射NewAccount到Account,第二次传递Account到repo以最终创建它.我的测试看起来像这样:
public class when_creating_an_account
{
static Mock<IRepository> _mockedRepository;
static AccountCreator _accountCreator;
static NewAccount _newAccount;
static Account _result;
static Account _account;
Establish context = () =>
{
_mockedRepository = new Mock<IRepository>();
_accountCreator = new AccountCreator(_mockedRepository.Object);
_newAccount = new NewAccount();
_account = new Account();
_mockedRepository
.Setup(x => x.Create(Moq.It.IsAny<Account>()))
.Returns(_account);
};
Because of = () => _result = _accountCreator.Create(_newAccount);
It should_create_the_account_in_the_repository = () => _result.ShouldEqual(_account); …Run Code Online (Sandbox Code Playgroud) 我有一个这样的表格:
<form id='myForm'>
<input type='text' name='search' />
<input type='text' name='maxPrice' />
</form>
Run Code Online (Sandbox Code Playgroud)
和我的jqGrid表:
<table id='myGrid'></table>
Run Code Online (Sandbox Code Playgroud)
我需要POST(不要GET)数据从myForm我的服务器方法,以获取行数据并填充网格.到目前为止,我还没有能够让jqGrid发布任何东西.我仔细检查了我的数据序列化,并正确地序列化我的表单数据.这是我的jqGrid代码:
$("#myGrid").jqGrid({
url: '/Products/Search") %>',
postData: $("#myForm").serialize(),
datatype: "json",
mtype: 'POST',
colNames: ['Product Name', 'Price', 'Weight'],
colModel: [
{ name: 'ProductName', index: 'ProductName', width: 100, align: 'left' },
{ name: 'Price', index: 'Price', width: 50, align: 'left' },
{ name: 'Weight', index: 'Weight', width: 50, align: 'left' }
],
rowNum: 20,
rowList: [10, 20, 30],
imgpath: gridimgpath,
height: 'auto',
width: '700',
//pager: $('#pager'), …Run Code Online (Sandbox Code Playgroud) 我有以下方法应该检索加载的本地(在bin文件夹)程序集的列表:
static IEnumerable<Assembly> GetLocalAssemblies()
{
Assembly callingAssembly = Assembly.GetCallingAssembly();
string path = new Uri(Path.GetDirectoryName(callingAssembly.CodeBase)).AbsolutePath;
var assemblies = AppDomain.CurrentDomain.GetAssemblies();
return assemblies.Where(x => !x.IsDynamic && new Uri(x.CodeBase).AbsolutePath.Contains(path)).ToList();
}
Run Code Online (Sandbox Code Playgroud)
但是,程序集列表缺少我需要它的几个程序集.我需要的程序集是管理的(c#.net 4),在项目中引用,并存在于bin文件夹中.
为什么bin文件夹中存在的二进制文件在应用程序启动时不会进入AppDomain?
c# ×5
javascript ×3
html ×2
.net ×1
assemblies ×1
collections ×1
cqrs ×1
css ×1
jqgrid ×1
jquery ×1
knockout.js ×1
mongodb ×1
moq ×1
nosql ×1
oracle ×1
refactoring ×1
reflection ×1
scrollbar ×1
sql ×1
types ×1
unit-testing ×1