- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
var taskMessages = from d in result
join ptask in db.ListingTask.Entites on new
{
d.Id,
TaskType = ListingTaskType.Offer.ToString()
} equals new
{
Id = ptask.DraftId,
ptask.TaskType
} into temp
from t in temp.DefaultIfEmpty()
select new
{
DraftId = d.Id,
OfferMessage = t == null || string.IsNullOrEmpty(t.Message) ? "无" : t.Message,
OfferSubmitResult = t == null || string.IsNullOrEmpty(t.Result) ? "无" : t.Result,
d.UserName,
d.UpdateTime,
d.Stock
};
在这个 LINQ 查询中,当我需要结果中的所有属性时,我需要在 select new {}
中编写每个属性,有没有简单的方法可以做到这一点?
最佳答案
将两个对象放入result对象中:
var taskMessages = from d in result
join ptask in db.ListingTask.Entites on new
{
d.Id,
TaskType = ListingTaskType.Offer.ToString()
} equals new
{
Id = ptask.DraftId,
ptask.TaskType
} into temp
from t in temp.DefaultIfEmpty()
select new
{
// you would obviously need better names
object1 = t,
object2 = d
};
然后像这样访问属性:
taskMessages[0].object2.UpdateTime; //Just as an example
更新(OP想直接使用结果中的所有属性):
您可以通过 C# 交互窗口中的反射获取所有属性的列表,并构造一个字符串输出以粘贴到您的代码中,如下所示:
#r "C:/MyApp/bin/Debug/Foo.dll"
using MyApp;
var myType = typeof(Person);
var myProperties = myType.GetProperties();
foreach(var myProperty in myProperties) { Console.WriteLine($"{myProperty.Name} = myObject.{myProperty.Name},"); }
Foo.dll 是您的程序集,也可以是一个 exe
关于c# - C#中如何将两个对象合二为一,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44278644/
我有这个, public enum Condition : uint // bitwise { None = 0, NewLine = 1, Space = 2 } Rule.
两条防线,一个函数: 试问你如何能保证客户端和服务器端具有相同的功能?表单域的验证闪现在我们眼前。别人把你的html复制到另外一个脚本,然后改变客户端的表单域验证--这并不是一件难事。摆
当我们打开此工作簿时,此代码将查看一个范围并找到包含文本“RCA Pending”的单元格,并将弹出一个 MsgBox,让用户知道该列中的哪一行包含特定文本。问题是,如果有多行包含此文本,也会有多个
我有一个 pandapower 网络,在一些公交车上,我将电池和光伏发电作为 FMU。现在我有一个主算法,可以在不同 FMU 的输入和输出之间创建连接并运行模拟。 我的问题是是否有可能将所有内容组合到
2 个不同的 jscript 合而为一: 我有 2 个 html 文件,其中有 2 个不同的 jscript。我想用 2 个 html 页面制作一个页面。我想在 1.html 按钮中添加 2.html
我的问题很简单,就是想把两张表拼成一张,不PK第一张表完全不同,它们完全不同 table1. table2. |в|q| |@|John | |ы|a|
我想弄清楚是否有办法将我的两个类合二为一。我的程序只是一个循环链表,我必须使用尽可能少的类。我还需要一些帮助来设置一种方法,让我用另一个节点替换一个节点。这是我的两个类(class)有什么想法吗? 第
我有 NSArray 和 NSArray。我想把所有的 NSArray 合二为一。 我认为有一个简单的函数可以使用,不是吗? 这是我收到的: ( ( n0eGi1KJW
向所有 CSS 专家致敬:D 我遇到了这种情况(在移动设备上): one two three four 我想,当通过@media处于横向模式时,将其更改为这样(不显示:无等): o
我想做的是将两个 or 查询与一个 and 查询结合起来 WHERE (id contains[cd] %@ OR name contains[cd] %@) AND manu = %@" 到目前为止
我正在尝试为游戏创建背景并有两个背景图像。我可以使用两个不同的 SKSpriteNode()、SKTexture、SKAction.sequence..etc 和一些数学将它们拼接在一起,但结果有点不
我有一个 HICON,我想将其用作另一个 HICON 的叠加层,以创建结果 HICON。结果 HICON 然后将用于“所有者绘制”控件(注意:它不使用图像列表)。覆盖图标具有透明颜色 RGB(0, 2
我正在修复我们在我们的一个网站上使用的模板,该模板具有以下代码 此代码段有效。 GS_googleAddAdSenseService("ca-pub-123"); GS_googleEna
我有以下 gulp 任务: gulp.task('app-scripts', function() { return getEnvScriptsStream() .pipe(
Perl 模板工具包 - 如何加入/连接多个变量(合为一个)例如,在 html 选择字段/组合中选择所选元素时需要它。 我在这里找到问题 https://www.perlmonks.org/?disp
我有一个 super 简单的网站,我想在本地托管。 我希望能够从网站触发windows程序并将结果返回给网站。 How can I accomplish this? Is this even poss
我遇到了这个问题,我在 中有一个 Logo 和一些导航链接。当我使用 CSS text-align:center; Logo 位于中心的一行,导航链接位于其正下方的另一行。 理想情况下,我希望它们并
我需要一个同时是 HashMap 和 ArrayList 的类。 为什么需要HashMap?根据键快速访问对象。 为什么我需要 ArrayList?随机选择一个元素。 你知道如何解决这个问题吗?有现成
我有一个模型类如下: public class CCP implements Serializable{ private static final long serialVersionUID
我正在使用 ReactiveCocoa 并且我有几个 SignalProducers let center = NSNotificationCenter.defaultCenter() let sig
我是一名优秀的程序员,十分优秀!