0

I am using EF4 in my application. In database, I have computed column which always null while fetching records from database using Linq query until current session alive. When session is lost then computed column value fetch successfully. Kindly suggest. Thanks

Yogesh
  • 829
  • 2
  • 8
  • 21

1 Answers1

0

you can use persist key word in your computed column declration.

ref:Example

Arian
  • 12,793
  • 66
  • 176
  • 300
  • I had already set 'Is Persisted'=Yes in database but still no success. – Yogesh Mar 13 '12 at 08:36
  • I don't have problem with Computed columns,please delete your table form your Data Model and regenrate it ind try again.and you can see definition for generated class and use profiler to see what sql sommand execute on server – Arian Mar 13 '12 at 08:45
  • The problem is that when I save new record and after context.commit(), I re-query with database to get saved record information based on generated ID within current session. In that case all information of generated ID comes except computed column value. But when I dispose current session then it works fine. Please suggest... – Yogesh Mar 13 '12 at 08:45
  • I have tested using sql profiler, which command sql profiler generates it works fine in sql query window but won't give desire result in linq query. – Yogesh Mar 13 '12 at 10:41
  • please see this topic : http://stackoverflow.com/questions/6944904/how-should-i-access-a-computed-column-in-entity-framework-code-first – Arian Mar 13 '12 at 10:43