我正在使用ASP.Net来渲染我的Angular 2应用程序,而我唯一的RAZOR页面是_Layout.cshtml,我希望能够将一些初始数据从RAZOR传递到我的自举组件中,但它不会似乎工作.
在我的_Layout.cshtml中,我有以下内容:
<my-app test="abc"></my-app>
Run Code Online (Sandbox Code Playgroud)
在我的app.component.ts中,我有:
import { Component, Input } from "@angular/core";
@Component({
selector: 'my-app',
template: "<div id='mainBody'>Test:{{test}}</div>",
directives: [MenuBarComponent, ROUTER_DIRECTIVES]
})
export class AppComponent {
@Input() test;
}
Run Code Online (Sandbox Code Playgroud)
我的测试变量是空白的.有没有不同的方法来做到这一点,还是只是不可能?
我在构建如何使用Entity Framework构建MVC应用程序到n层应用程序时遇到了一些麻烦.
正常的教科书3层应用应该看起来像
数据访问 - >业务逻辑 - >演示
演示文稿不应该知道有关数据访问的任何信息.使用EF,所有图层都需要了解模型.所以我的架构现在看起来更像
Data Access->Business Logic
| |
---------------
|
MVC
Run Code Online (Sandbox Code Playgroud)
我在这里遗漏了什么,或者我是以错误的方式思考这个问题的?
我是否应该将EF本身视为数据访问层并将实体置于业务逻辑中?
我有以下代码,其中T是通用定义如下:
public abstract class RepositoryBase<T> where T : class, IDataModel
Run Code Online (Sandbox Code Playgroud)
这段代码工作得很好:
PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName);
if (propertyInfo.DeclaringType.FullName == typeof(T).FullName) <--- Works just fine
Run Code Online (Sandbox Code Playgroud)
vs这个评估为false的代码
PropertyInfo propertyInfo = typeof(T).GetProperty(propertyName);
if (propertyInfo.DeclaringType is T) <-- does not work
Run Code Online (Sandbox Code Playgroud)
我在这做错了什么?
我有几个共享映射代码的ASP.Net应用程序,所以我创建了一个通用的automapper init类.
但是,在我的一个应用程序中,我有一些特定的类要添加到配置中.
我有以下代码:
public class AutoMapperMappings
{
public static void Init()
{
AutoMapper.Mapper.Initialize(cfg =>
{
... A whole bunch of mappings here ...
}
}
}
Run Code Online (Sandbox Code Playgroud)
和
// Call into the global mapping class
AutoMapperMappings.Init();
// This erases everything
AutoMapper.Mapper.Initialize(cfg => cfg.CreateMap<CustomerModel, CustomerInfoModel>());
Run Code Online (Sandbox Code Playgroud)
如何在不破坏已初始化的内容的情况下添加此唯一映射?
我有以下代码:
public static void UploadStreamToBlob(Stream stream, string containerName, string blobName)
{
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
blobContainer.CreateIfNotExists();
blobContainer.SetPermissions(
new BlobContainerPermissions
{
PublicAccess = BlobContainerPublicAccessType.Blob
});
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobName);
long streamlen = stream.Length; <-- This shows 203 bytes
blockBlob.UploadFromStream(stream);
}
Run Code Online (Sandbox Code Playgroud)
和
public static Stream DownloadStreamFromBlob(string containerName, string blobName)
{
CloudStorageAccount storageAccount =
CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference(containerName);
Stream stream = new MemoryStream();
CloudBlockBlob blockBlob = blobContainer.GetBlockBlobReference(blobName);
if (blockBlob.Exists())
{ …Run Code Online (Sandbox Code Playgroud) 我一直在阅读无数关于如何使用最佳实践构建新的MVC 3应用程序的文章.
90%的文章将EF EDMX文件合并到与MVC应用程序相同的项目中.那些将这些项目分成他们自己的项目的人并没有说明每个项目进入哪个项目以及每个项目有哪些参考.通常它们由代码片段组成,这些代码片段非常适合教授如何执行特定功能,但不告诉我如何构建解决方案.
我相信我的解决方案中至少需要5个项目.任何人都能告诉我这里是否有正确的布局?
这看起来不错吗?有人能指出我使用ViewModels,AutoMapper,Repository模式和EF4进行n层开发的好文章吗?
repository-pattern n-tier-architecture automapper asp.net-mvc-3
我有以下代码......
<div ng-controller="CalendarCtrl">
<input type="text" ng-model="model.selectedDate" ng-change="onCalendarChange()" id="calendar" />
</div>
<script>
var app = angular.module("myApp", []);
app.controller("CalendarCtrl", function($scope) {
var currentDate = new Date();
$scope.model = { selectedDate: (currentDate.getMonth() + 1) + "/" + currentDate.getDay() + "/" + currentDate.getFullYear() };
console.log($scope.model);
$scope.onCalendarChange = function() {
console.log(currentDate);
};
});
$(document).ready(function() {
$("#calendar").datepicker();
});
</script>
Run Code Online (Sandbox Code Playgroud)
此代码似乎工作得很漂亮.正在调用change事件并正确显示新的selectedDate.
然而,我一直看到开发人员正在使用各种箍(主要是指令)的帖子,以使日期选择器在Angular中工作.
我在这里错过了什么吗?
我认为Silverlight 4.0是构建业务应用程序的不错选择.
然而,我害怕的一部分是装载.如果我理解正确,Silverlight会将所有页面编译成一个二进制文件,在加载时加载到客户端上.现在只需几页就可以了,但如果我达到数百页,这个加载时间会变得非常长吗?当我查看Infragistics和Telerik的示例时,他们需要10-15秒才能加载这几个示例.我发现这是不可接受的.
有办法解决这个问题吗?
我需要在不触发对任何订阅的下一次调用的情况下设置我的 BehaviorSubject 的值。
我尝试这样做:
this.mySubject = new BehaviorSubject(newVal);
Run Code Online (Sandbox Code Playgroud)
但这也会删除所有订阅。
this.mySubject.value = newVal;
Run Code Online (Sandbox Code Playgroud)
不起作用,因为.value是只读的。
有什么办法可以做到这一点吗?
编辑:对于那些问我为什么需要这样做的人...
这是一个 Ionic 4 应用程序,因此有一个根列表页面调用另外 2 个子页面(一个详细信息视图和一个编辑页面)。进入视图页面的第一个导航需要选择的模型。列表页面将此模型的初始值设置到 BehaviorSubject 中,然后导航到视图页面。但是,这个初始值的设置会触发列表的刷新,这是我不想做的。我只想初始化该值,然后监听以防编辑页面更改它,然后刷新我的列表。
在 Asp.Net Core 中,他们似乎已经取消了Request.Content.ReadAsMultipartAsync支持 IFormFile的功能。
这使得在您拥有实际文件的地方上传更容易,但是,我有一个用例,我需要将文件上传到浏览器内存,对其进行处理,然后将其作为正文中多格式数据的一部分发送。IFormFile 无法看到这一点,因为没有要读取的实际文件。只有当您在 Content-Disposition 上有一个文件名属性并且在客户端上有一个要上传的实际文件时,它才有效。
在我的 Asp.Net 4 应用程序中,无论是在边界之间发送还是作为附件发送,我都可以读取正文中的多部分数据。
我如何在 .Net Core 中实现这一点?
angular ×2
automapper ×2
c# ×2
angularjs ×1
architecture ×1
asp.net-core ×1
asp.net-mvc ×1
azure ×1
jquery-ui ×1
loading ×1
properties ×1
reflection ×1
rxjs ×1
streaming ×1