我们希望使用Entity Framework Code First使用一对一的可选关系.我们有两个实体.
public class PIIUser
{
public int Id { get; set; }
public int? LoyaltyUserDetailId { get; set; }
public LoyaltyUserDetail LoyaltyUserDetail { get; set; }
}
public class LoyaltyUserDetail
{
public int Id { get; set; }
public double? AvailablePoints { get; set; }
public int PIIUserId { get; set; }
public PIIUser PIIUser { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
PIIUser可能有LoyaltyUserDetail但LoyaltyUserDetail必须有PIIUser.我们尝试了这些流畅的方法技巧.
modelBuilder.Entity<PIIUser>()
.HasOptional(t => t.LoyaltyUserDetail)
.WithOptionalPrincipal(t => t.PIIUser)
.WillCascadeOnDelete(true);
Run Code Online (Sandbox Code Playgroud)
这种方法没有 …
我的代码发出https请求.这是我的代码
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(UploadUrl);
request.Method = "POST";
request.KeepAlive = false;
request.Credentials = new NetworkCredential(userid, testpwd);
postData = "<root></root>";
request.ContentType = "application/x-www-form-urlencoded";
byte[] postDataBytes = Encoding.UTF8.GetBytes(postData);
request.ContentLength = postDataBytes.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postDataBytes, 0, postDataBytes.Length);
requestStream.Close();
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
StreamReader responseReader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
var result = responseReader.ReadToEnd();
responseReader.Close();
Console.WriteLine(result);
}
Run Code Online (Sandbox Code Playgroud)
这段代码运行良好但突然抛出异常
Run Code Online (Sandbox Code Playgroud)System.Net.WebException异常消息是:基础连接已关闭:发送时发生意外错误.
堆栈跟踪:位于System.Net.HttpWebRequest.GetRequestStream(TransportContext&context)的System.Net.HttpWebRequest.GetRequestStream(),位于CustomerProcessor.Delivery.Deliver(String content,Int32 productCategory,String identifier,String xsltFile)
Exception有一个内部异常:发生异常:System.IO.IOException异常消息是:从传输流中收到意外的EOF或0字节.
堆栈跟踪:System.Net上的System.Net.FixedSizeReader.ReadPacket(Byte []缓冲区,Int32偏移量,Int32计数)处于System.Net的System.Net.Security.SslState.StartReadFrame(Byte []缓冲区,Int32 readBytes,AsyncProtocolRequest asyncRequest).在System.Net.Security.SslState.StartSendBlob(Byte []传入,Int32计数,System.SNet.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken消息,AsyncProtocolRequest asyncRequest)上的Security.SslState.StartReceiveBlob(Byte []缓冲区,AsyncProtocolRequest asyncRequest),位于System.Net.TlsStream.CallProcessAuthentication(对象状态)的System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)的System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst,Byte [] buffer,AsyncProtocolRequest asyncRequest)中的AsyncProtocolRequest asyncRequest) …
new ListView(
children: [
new SizedBox(
height: 100.0,
child: ListView(
scrollDirection: Axis.horizontal,
children: <Widget>[
new Text("hi"),
new Text("hi"),
new Text("hi"),
],
),
),
],
),
Run Code Online (Sandbox Code Playgroud)
我使用了大小的盒子,似乎仍然有错误.
这是我的小部件树:SingleChildScrollView - > Column - > children
Performing hot reload... flutter: ??? EXCEPTION CAUGHT BY RENDERING LIBRARY ?????????????????????????????????????????????????????????? flutter: The following assertion was thrown during performResize(): flutter: Vertical viewport was given unbounded height. flutter: Viewports expand in the scrolling direction to fill their container.In this case, a vertical flutter: viewport was given an unlimited …Run Code Online (Sandbox Code Playgroud) 我有这样一个模型的列表
amount:"12000"
dateTime:"19/07/2018"
detail:"Soto"
hashCode:853818549
id:1
name:"Theodorus"
Run Code Online (Sandbox Code Playgroud)
我只想选择数量并将其添加到另一个字符串列表中,但我总是收到此错误A value of type 'String' can't be assigned to a variable of type 'List<String>'. ,我认为这是因为我没有做对,下面是我的代码
void setupList() async {
DebtDatabase db = DebtDatabase();
listCache = await db.getMyDebt();
setState(() {
filtered = listCache;
});
List<String> amount = new List<String>();
listCache.map((value) {
amount = value.amount; } );
//print(amount);
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮助我,所以我可以从这个模型列表中获取数量列表,然后总结所有的数量?
我的 showDialog 有问题,当我按下没有任何反应但如果我使用Navigator.pushNamed(context, "/screen1")它就可以了。我无法运行Navigator.pop(context),它不会返回任何错误。
_showDialog(BuildContext context) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: new Text("Alert Dialog title"),
actions: <Widget>[
new FlatButton(
child: new Text("Back"),
onPressed: () {
//Navigator.pushNamed(context, "/screen1");
Navigator.pop(context);
},
),
],
);
});}
Run Code Online (Sandbox Code Playgroud)
在我的 build() 中:
IconButton(
iconSize: 30.0,
onPressed: () => _showDialog(context),
icon: Icon(
Icons.clear,
color: Colors.white,
),
Run Code Online (Sandbox Code Playgroud)
)
我正在使用 GraphQL 创建一个订阅,我需要使用 Flutter 使用该订阅,但我不知道如何做到这一点,我需要的东西就像一个与订阅相关联的 UI 组件,它会会自动刷新。
我将不胜感激任何反馈。
我遵循了将 EF Core 与 ASP.NET Core 一起使用的模式,一切都很好。但最近我创建了一个“计算”项目,并希望从中进行数据库调用。
问题是我不知道如何创建一个新的DbContextOptions. 在我完成的代码中
services.AddDbContext<RetContext>(options => options
.UseLazyLoadingProxies()
.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
Run Code Online (Sandbox Code Playgroud)
但是在新的 .NET 核心类中,我需要手动提供它。我该怎么做呢 ?我的代码是这样的:
public static class LoadData
{
public static IConfiguration Configuration { get; }
public static RefProgramProfileData Load_RefProgramProfileData(string code)
{
// var optionsBuilder = new DbContextOptionsBuilder<RetContext>();
// optionsBuilder.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"));
//How do I make an optionsbuilder and get the configuration from the WEB project?
UnitOfWork uow = new UnitOfWork(new RetContext(optionsBuilder));
var loadedRefProgramProfileData = uow.RefProgramProfileDataRepository
.Find(x => x.ProgramCode == code).FirstOrDefault();
return loadedRefProgramProfileData;
}
}
Run Code Online (Sandbox Code Playgroud) c# entity-framework dependency-injection entity-framework-core asp.net-core
dart ×4
flutter ×4
c# ×2
.net ×1
asp.net-core ×1
graphql ×1
http ×1
one-to-one ×1
subscription ×1