gpt4 book ai didi

c# - 如何在 LINQ to SQL 查询中以大写形式输出列?

转载 作者:行者123 更新时间:2023-11-30 13:24:57 26 4
gpt4 key购买 nike

我想在我的 LINQ 查询中使用 UCASE 或 ToUpper 列。

var query = from rsn in db.RSLReasons
orderby rsn.REFCMNT
select new {rsn.REFCODE, rsn.REFCMNT};
dtReasons = query.ToADOTable(rec => new object[] { query });

如果我尝试运行以下代码:

var query = from rsn in db.RSLReasons
orderby rsn.REFCMNT
select new {rsn.REFCODE, rsn.REFCMNT.ToString()};
dtReasons = query.ToADOTable(rec => new object[] { query });

我在编译时收到以下错误消息:

Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.

最佳答案

使用 ToUpper()... 但您需要以匿名类型指定属性名称,因为它无法再被推断。

var query = from rsn in db.RSLReasons
orderby rsn.REFCMNT
select new {rsn.REFCODE, REFCMNT = rsn.REFCMNT.ToUpper()};

dtReasons = query.ToADOTable(rec => new object[] { query });

关于c# - 如何在 LINQ to SQL 查询中以大写形式输出列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1422570/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com