how to store dynamically the desired value in my linqued query variable


I have this query

var empno = (from LApp in db.Employees select new { LApp.EmployeeNumber }).ToList();

when executed I have this in empno

<a href="https://i.stack.imgur.com/oO45q.png" rel="nofollow"><img alt="enter image description here" class="b-lazy" data-src="https://i.stack.imgur.com/oO45q.png" data-original="https://i.stack.imgur.com/oO45q.png" src="https://etrip.eimg.top/images/2019/05/07/timg.gif" /></a>

what I want is to trim the starting zeros and store it in empno

i.e {EmployeeNumber="2"} and so on... How is it possible?


You can use <a href="https://msdn.microsoft.com/en-us/library/system.string.trimstart%28v=vs.110%29.aspx" rel="nofollow">TrimStart()</a> to remove leading zeros, something like this :

var empno = (from LApp in db.Employees select new { EmployeeNumber = LApp.EmployeeNumber.TrimStart('0') } ).ToList();

I have no idea if TrimStart() can be translated to SQL, you might need AsEnumerable() if TrimStart() turned out not supported.


  • WCF async method calling hangs up?
  • Can I add an XML declaration to an XSLT output?
  • Possible to combine .csv where-object filters?
  • ERROR: syntax error at or near “OVER”
  • JTable does not show anything?
  • how to keep many to many relationships in sync with nhibernate?
  • How to access nested Json Data in AmCharts
  • Beginner sql join query
  • Application with fake data source for UI development
  • Creating ORACLE PL/SQL store procedures with different kind of AND conditions
  • Print dynamic Excel page with changing content
  • How to show DataColumns in Dataset DataTable
  • Format MySQL using CONCAT
  • want to write trigger for two different databases in Mysql
  • Take data from different tables and display it in View Index in mvc4
  • Relay Error when deleting: RelayMutationQuery: Invalid field name on fat query
  • How can I retrieve all employees whose age will be 21 in a month's time?
  • Multi-line JSON read using Apache PIG
  • ObjectMaterialize in EF not firing on first level query
  • get data from firestore firebase
  • C# “cannot assign field because it is a foreach iteration variable”
  • How to bind comma separated list of values to List
  • Excel 2007: Format of email address from Outlook 2007
  • Updating and removing unique join relationships in CakePHP
  • Stitching 2 images (OpenCV)
  • Negating Regex PO BOX
  • NHibernate manually control fetching
  • How can I run DataNucleus Bytecode Enhancer from SBT?
  • Jquery Knockout: ko.computed() vs classic function?
  • PostgreSQL Query without WHERE only ORDER BY and LIMIT doesn't use index
  • ActionScript 2 vs ActionScript 3 performance
  • Display Images one by one with next and previous functionality
  • ORA-29908: missing primary invocation for ancillary operator
  • How to get next/previous record number?
  • SQL merge duplicate rows and join values that are different
  • using HTMLImports.whenReady not working in chrome
  • How do you join a server to an Active Directory (domain)?
  • How does Linux kernel interrupt the application?
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection