In MSSQL you can convert a string into an integer like this:
CONVERT(INT, table.column)
Is there any C# expression that Linq to SQL would t
Convert.ToInt32 should work. Check out this article for information on the translations.
for LINQ to entities, if it is simply a mismatch between your model and the DB you can overcome this using a valueconverter with EF Core.
public OnModelCreating(ModelBuilder modelBuilder) {
modelBuilder.Entity<mymodel>()
.Property(e => e.myModelIntColumn) // this column is a string in the db
.HasConversion(new ValueConverter<int?, string>(m => m.HasValue ? m.ToString().Substring(0,10) : null, db => int.Parse(db ?? "0")));
}
and in my LINQ i can then use bit comparison:
MyDBSet.Where( e => (BitsWanted == 0 || ( e.myModelIntColumn & BitsWanted ) > 0));
C# has Convert.ToInt32() which should do what you're looking for.