Use "from" property in linq

in my class i have a property named "from" but i cant use it in my linq statement?

is there any solution or should i change my property name?

lst1 = (from p in db.adv where p.isShowInMainPage && p.isShowInHeader && (p.from <= DateTime.Now)  orderby p.id descending select p);

lst2= (from p in db.adv where p.isShowInMainPage && !p.isShowInHeader orderby p.id descending select p);

      

when i use p.from compile error:

Error   14  ; expected  

      

in SQL, we could use [] ([from]). is there something like this in LINQ

+3


source to share


2 answers


In (@from) at the beginning should work in C #, in VB.NET you use [from]



+4


source


You can do as @Ales says and use the @ symbol in front of the property name. Alternatively, you can rename your property to From

using the Pascal wrapper - .NET design guidelines in capitalization conventions suggest using Pascal enclosure for properties.



+1


source







All Articles