我正在寻找一种将对象列表序列化为谷歌图表json数据格式的通用方法.
这个例子非常接近,但它使用的是数据表..
我希望这会涉及一些反思,有些可能是模型属性的内容.谁能指点我到图书馆或什么的?
如果我可以将这样的查询序列化为谷歌图表格式,那就更好了:
var results = from m in be.cmsMember
where m.FirstLogin != null
&& m.FirstLogin >= BitCoinGoLive
group m by
new { Year = m.FirstLogin.Value.Year, Month = m.FirstLogin.Value.Month, Day = m.FirstLogin.Value.Day } into grp
select new
{
Year = grp.Key.Year,
Month = grp.Key.Month,
Day = grp.Key.Day,
Count = grp.Count()
};
Run Code Online (Sandbox Code Playgroud) 我想创建一个新的EF对象,它引用另一个对象(在我的示例中为aspnet userId),而不加载外部(键)对象.
所以基本上我想做以下事情:
buskerSet bs = new buskerSet();
bs.Title = title;
bs.Image = image;
bs.Created = DateTime.Now;
//The following will crash, because bs.aspnet_Users is null
bs.aspnet_Users.UserId = userId;
context.SaveChanges();
Run Code Online (Sandbox Code Playgroud)
在bs.aspnet_UsersReference中我找不到任何有用的东西..
解:
aspnet_Users user = new aspnet_Users { UserId = userId };
context.AttachTo("aspnet_Users", user);
set.aspnet_Users = user;
Run Code Online (Sandbox Code Playgroud) 用户将他们的MP3发布到我的网站,我想在文件存储到CDN之前从文件中读取元数据.TagLib-Sharp似乎是为此而去的库,但是我看不到任何打开HttPostedFile的方法,我不想将其保存到磁盘,并检索元数据.
任何人都有一个关于如何用taglib-sharp做到这一点的例子?
编辑:似乎IFileAbstraction可以解决这个问题.谁知道如何使用IFileAbstraction?
我正在将文档存储在数据库中,并具有用于下载文档的API.
docx和xlsx的下载在IE9,Chrome和FF中运行良好但在真正的IE8中失败.(IE8模式下的IE 9也可以)
我得到的错误消息如下:
无法从idler2下载393.
无法打开此Internet站点.请求的网站不可用或无法找到.请稍后再试.
使用以下响应头:HTTP/1.1 200 OK Cache-Control:no-cache Pragma:no-cache
Content-Length: 10255
Content-Type: application/octet-stream
Expires: -1
Server: Microsoft-IIS/7.5
Content-Disposition: attachment; filename=document.docx
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 23 Mar 2013 11:30:41 GMT
Run Code Online (Sandbox Code Playgroud)
这是我的api方法:
public HttpResponseMessage GetDocumentContent(int id)
{
Document document = Repository.StorageFor<Client>().GetDocument(id);
HttpResponseMessage response = Request.CreateResponse(System.Net.HttpStatusCode.OK);
response.Content = new ByteArrayContent(document.GetBuffer());
response.Content.Headers.ContentLength = document.GetBuffer().Length;
response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
{
//FileName = document.GetFileName(),
FileName = "document.docx",
DispositionType = "attachment"
};
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
return response;
}
Run Code Online (Sandbox Code Playgroud)
我在内容配置和内容标题上尝试了很多变化,但没有运气..
出于某种原因,开发jQuery模板插件(jquery-tmpl)已被搁置.从阅读有关该主题的博客博客文章来看,它似乎将在未来再次被包含或被具有不同方法的东西取代(例如jsRender和jsViews)
在jQuery中实现模板化的未来证明方法是什么?(使用beta的东西是好的)
我正试图从我的c#app发送midi信号到Ableton Live的一首曲目.
我已经尝试过Bass.net和midi-dot-net都具有相同的效果:没有任何事件到达Ableton.(我已经安装了loopMidi,这就是我发送信号的地方.)
奇怪的是,当我瞄准我的midi键盘时,它播放标准的钢琴声音..
我的代码是网站上的示例的1-1副本:
OutputDevice outputDevice = OutputDevice.InstalledDevices[0];
outputDevice.Open();
outputDevice.SendNoteOn(Channel.Channel1, Pitch.C4, 80); // Middle C, velocity 80
outputDevice.SendPitchBend(Channel.Channel1, 7000); // 8192 is centered, so 7000 is bent down
Run Code Online (Sandbox Code Playgroud)
因为我还不熟悉midi,我觉得我仍然误解了一些基础知识.有人能看出我做错了什么吗?
我想对一个控制器进行单元测试,该控制器会在属性发生变化时触发事件.
控制器看起来像这样:
App.MyController = Ember.Controller.extend({
...
observeFilterFieldChanges: function() {
console.log("observeFilterFieldChanges");
this.setActiveSortField();
this.send("queryChanged");
}.observes("sorting.fields.@each.active"),
...
});
Run Code Online (Sandbox Code Playgroud)
我的测试如下:
test('changing sort field via sort.fields will trigger query changed', function () {
var queryChangedCalled = false;
var tmpListController = App.MyController.create({
actions: {
queryChanged: function () {
console.log("querychanged called from controller");
queryChangedCalled = true;
}
}
});
// trigger the change
tmpListController.set("sorting.fields.0.active", true);
stop();
// not sure if I need to wait for the run loop to finish
Ember.run.schedule('afterRender', this, function () {
start();
ok(queryChangedCalled, …Run Code Online (Sandbox Code Playgroud) 我有一些通常看起来像这样的集成测试:
test('can load with available teams', function () {
visit('/workforce/admin/organizations/create').then(function () {
var controller = App.__container__.lookup('controller:organizations.create');
...
});
});
Run Code Online (Sandbox Code Playgroud)
App .__容器中的下划线表示(至少对我来说),这是一个私有财产,不应在外部访问.
有没有更好的方法/模式来实现这一目标?
我有一个在mongoose和express上运行的node.js REST服务.我也使用merse来设置我的路由.
我现在想要实现的是以下类型的sceanrios:
Scenario I: e.g. blogpost
- GET -> no authentication required
- POST/PUT/DELETE -> authentication required
Scenario II: e.g. user
- GET -> authentication required
- POST/PUT/DELETE -> authentication required plus username of logged in user has to match
Run Code Online (Sandbox Code Playgroud)
我已经看过everyauth和mongoose-auth了,但找不到能给我这种控制的东西.
我有模型的骨干集合,并希望检索某个属性的不同值
如果我将以下数据加载到我的集合中:
[{brand:'audi',id:'1234'},
{brand:'audi',id:'3456'},
{brand:'bmw',id:'3456'}]
Run Code Online (Sandbox Code Playgroud)
我现在想要从该系列中获得独特的品牌.结果应该是:
['audi','bmw']
Run Code Online (Sandbox Code Playgroud)
看看Backbone和Underscore API我没有看到任何明显的事实.我目前的方法是使用像jslinq这样的库
我错过了什么明显的或者有人比jslinq有更好的建议吗?
c# ×3
ember.js ×2
ableton-live ×1
backbone.js ×1
express ×1
jquery ×1
midi ×1
mp3 ×1
node.js ×1
taglib-sharp ×1
templating ×1