我正在使用旧的SQL Server 2000数据库,将其中的一些信息与我正在构建的新应用程序混合.我注意到几个表中的一些主键是浮点数而不是任何类型的整数.它们不是外键,而且都是独一无二的.我想不出任何人会想让他们唯一的主键ID浮动,但我不是任何SQL专家.所以我想我所问的是,设计这个相当广泛的数据库的人是否知道我不知道的事情?
我有一个普通的旧CLR对象,它本质上是两个实体框架对象的包装器,我这样做,所以我可以将这个包装器对象传递给MVC框架中的强类型视图.我的foo包装类非常简单:
public class FooWrapper
{
public FooWrapper(Foo f, Bar b)
{
this.FooObject = f;
this.BarObject = b;
}
public Foo FooObject { get; private set; }
public Bar BarObject { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,我的ListFoosWithBars函数具有以下内容:
public IEnumerable<FooWrapper> ListFoosWithBars(int userID)
{
IEnumerable<Bar> tempBar = ListBarsByUserID(userID);
IEnumerable<FooWrapper> results = (from f in _entities.FooSet
join b in tempBar on f.ID equals b.foos.ID
select new FooWrapper(f, b));
return results;
}
Run Code Online (Sandbox Code Playgroud)
这不起作用,因为显然LINQ to Entities不支持参数化初始化,抛出的异常只是说:"LINQ to Entities中只支持无参数构造函数和初始值设定项." 我想知道是否有另一种方法来实现同样的结果?
我收到以下错误,但在它正在发生的上下文中似乎无法理解它:
消息路径'PROPFIND'被禁止.System.Web.HttpMeth上的System.Web.HttpMethodNotAllowedHandler.ProcessRequest(HttpContext上下文)中的StackTrace,System.Web.HttpApplication.ExecuteStep(IExecutionStep step,Boolean&completedSynchronously)上的System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
Google已经发现了与我的应用程序似乎没有任何关系的结果(这是IIS6上的asp.net MVC).该网站运行正常,但我想尝试抓住并处理此错误.谢谢.
根据这个问题中有关如何使用当前项目的依赖关系加载iex 的建议,我能够以非常高效的方式使用phoenix框架依赖项.但是,为每一件事提供Phoenix项目的命名空间都会有点乏味.
而不是打字,MyApp.Repo.all(MyApp.User)我希望能够做到Repo.all(User).我可以单独为每个东西添加别名,alias MyApp.Repo, as: Repo但有没有办法一次性完成所有这些操作?
我在QUnit中设置了以下内容:
/* Dozen or so previous tests here */
test("Test some markup generation", function () {
$('#qunit-fixture').plugin(); // jQuery plugin: Generates a table
var rows = $('#qunit-fixture table tbody tr');
count = rows.length; // Count the rows
console.log(count);
equal(count, "96", "Expect the number of rows to be 96");
});
Run Code Online (Sandbox Code Playgroud)
当它运行时,或者当我刷新浏览器时,它交替地使该测试显示count = 0,或者通过它并且失败所有先前的测试.测试之外没有定义全局变量.如果我手动将计数设置为96,一切都很顺利,或者如果我删除了这个测试,或者所有以前的测试,一切都会通过.我想知道是否有人遇到过这种行为?我已经使用了很多QUnit,之前没有遇到过这种情况.
在亚历克斯詹姆斯的实体框架提示文章,(顺便说一句,这是很好的)他谈到如何假冒外国关键属性.这似乎正是我所需要的,但无论出于何种原因,我在更新时似乎无法将其拉下来.我在控制器的更新部分有以下内容:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(candidates candidateToEdit)
{
string EduIDValue = candidateToEdit.education.ID.ToString();
if (!ModelState.IsValid)
return View();
try
{
var originalCandidate = (from c
in model.candidates
where c.ID == candidateToEdit.ID select c).FirstOrDefault();
//attempting it here
originalCandidate.educationReference.EntityKey = new System.Data.EntityKey("model.education", "ID", candidateToEdit.education.ID);
model.ApplyPropertyChanges(originalCandidate.EntityKey.EntitySetName, candidateToEdit);
model.SaveChanges();
return RedirectToAction("Index");
}
catch(Exception e)
{
Response.Write("Education ID Value " + EduIDValue + "<br /><br />Error: <br /><br />" + e);
return null;
//return View();
}
}
Run Code Online (Sandbox Code Playgroud)
这失败并吐出以下内容:
System.ArgumentException:元数据集合中不存在具有标识"model"的成员.参数名称:System.Data.Metadata上的System.Data.Metadata.Edm.MetadataCollection 1.GetValue(String identity, Boolean ignoreCase) at …
我想知道是否有任何方式只使用CSS,(这可能是浏览器特定的CSS)将所有大写文本转换为最初仅大写的单词,例如:
I YELL WITH MY KEYBOARD
将被转换为:
I Yell With My Keyboard
编辑:我意识到我在我的问题中不够清楚,文本输入大写,而不是最初的小写,文本转换:大写不适用于像这样输入的数据.
我应该从控制器访问asp.net成员资格类并将结果传递给服务层,还是直接从服务层访问它?
我撕掉了,因为一方面这似乎是应该在服务层来处理业务逻辑,但我不希望将服务层系在网络命名空间,因为这可能会成为一个Windows应用程序的道路.
在过去的几个月里,我一直在阅读有关TDD的很多内容,并决定试着用一个简单的例子来试一试,我只是不确定我是否在实践中测试正确的东西.这里是用于验证电子邮件的自定义数据注释的测试:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace MembershipTest.Tests
{
[TestClass]
public class CustomDataAnnotationsTest
{
[TestMethod]
public void CustomDataAnnotations_Email_ReturnTrueIfNull()
{
// Arrange
EmailAttribute attribute = new EmailAttribute();
// Act
bool result = attribute.IsValid(null);
// Assert
Assert.AreEqual(true, result);
}
[TestMethod]
public void CustomDataAnnotations_Email_ReturnFalseIfInvalid()
{
// Arrange
EmailAttribute attribute = new EmailAttribute();
// Act
bool result = attribute.IsValid("()[]\\;:,<>@example.com");
// Assert
Assert.AreEqual(false, result);
}
[TestMethod]
public void CustomDataAnnotations_Email_ReturnTrueIfValid()
{
// Arrange
EmailAttribute attribute = new EmailAttribute();
// Act
bool …Run Code Online (Sandbox Code Playgroud) asp.net-mvc ×4
asp.net ×3
asp-classic ×1
asp.net-3.5 ×1
css ×1
elixir ×1
elixir-mix ×1
html ×1
http ×1
iex ×1
iis-6 ×1
javascript ×1
jquery ×1
linq ×1
markdown ×1
markup ×1
qunit ×1
sql ×1
tdd ×1
testing ×1
unit-testing ×1
vbscript ×1