我正在尝试像Linq中的Excel / SQL一样执行LEFT功能但是我很难理解我自己的代码上下文中的子字符串
我有以下代码
var q = from hed in cxt.SOPOrderReturns.ToExpandable()
join cus in cxt.SLCustomerAccounts on hed.CustomerID equals
cus.SLCustomerAccountID
join ad in cxt.SOPDocDelAddresses on hed.SOPOrderReturnID equals
ad.SOPOrderReturnID
join os in cxt.JH_FINALSOPOrderSalesSeachLinks on hed.SOPOrderReturnID
equals os.SOPOrderReturnID
where os.OrderStatus == "despatched" || os.OrderStatus == "part
despatched"
select new
{
hed.SOPOrderReturnID,
hed.DocumentNo,
hed.DocumentDate,
cus.CustomerAccountNumber,
cus.CustomerAccountName,
hed.CustomerDocumentNo,
ad.PostalName,
ad.City,
hed.TotalNetValue,
OrderType = hed.AnalysisCode1,
Route = hed.AnalysisCode2,
WAD = hed.AnalysisCode3,
hed.PromisedDeliveryDate,
ad.PostCode,
};
q = q.RemoveExpandable();
return q;
在ad.PostalName行上,我在开头有一个4位数的代码,例如0001 - 示例邮戳名称
我想显示此行的前4位数字,但我很难做到这一点。
提前致谢
杰米
答案 0 :(得分:1)
只需使用正常的表达式。
childClass