Linq and Validation Application Block (Enterprise Library)

  • Thread starter Thread starter Evert
  • Start date Start date
E

Evert

Does anybody know if it is possible to use the Validation Application Block
from Enterprise Library 3.1 in Linq. The problem is that I don't know how to
add the validation attributes to the generated properties.

Thanks in advance,

Evert
 
Evert,

You can't through the designer. There is no way to add attributes
through the designer to the classes. You could modify the
designer-generated code, but it might be overwritten by the designer.

There is no good solution to this, I am afraid.
 
Hmm... I am searching for a good technology for my new application. (Sort of
time management on web). I thought the Validation Application Block was good
for my business objects. And LINQ to SQL is good for getting the data from
the database. But if it is not possible to use the VAB i can't use linq.

Do you have a better solution? I like the VAB a lot. It is easy to use, fast
to program and very sollid. With the AJAX validation controls it is also easy
to use in the GUI.

Best regards,

Evert


Nicholas Paldino said:
Evert,

You can't through the designer. There is no way to add attributes
through the designer to the classes. You could modify the
designer-generated code, but it might be overwritten by the designer.

There is no good solution to this, I am afraid.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Does anybody know if it is possible to use the Validation Application
Block
from Enterprise Library 3.1 in Linq. The problem is that I don't know how
to
add the validation attributes to the generated properties.

Thanks in advance,

Evert
 
Evert,

Well, there is no reason you can't code the objects that LINQ uses
yourself. You can then apply whatever attributes you wish. You can easily
create class definitions which LINQ can use.

Here is a link to the section of the MSDN documentation titled "The LINQ
to SQL Object Model", which should help:

http://msdn2.microsoft.com/en-us/library/bb386989.aspx

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Hmm... I am searching for a good technology for my new application. (Sort
of
time management on web). I thought the Validation Application Block was
good
for my business objects. And LINQ to SQL is good for getting the data from
the database. But if it is not possible to use the VAB i can't use linq.

Do you have a better solution? I like the VAB a lot. It is easy to use,
fast
to program and very sollid. With the AJAX validation controls it is also
easy
to use in the GUI.

Best regards,

Evert


Nicholas Paldino said:
Evert,

You can't through the designer. There is no way to add attributes
through the designer to the classes. You could modify the
designer-generated code, but it might be overwritten by the designer.

There is no good solution to this, I am afraid.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Does anybody know if it is possible to use the Validation Application
Block
from Enterprise Library 3.1 in Linq. The problem is that I don't know
how
to
add the validation attributes to the generated properties.

Thanks in advance,

Evert
 
Hi Nicholas,

Can you tell me what you mean with code myself? Do I need to code sort-of
copies of the LINQ entities that are created? How do I fill these entities?
Do I need to do this manually?

Br,

Evert

Nicholas Paldino said:
Evert,

Well, there is no reason you can't code the objects that LINQ uses
yourself. You can then apply whatever attributes you wish. You can easily
create class definitions which LINQ can use.

Here is a link to the section of the MSDN documentation titled "The LINQ
to SQL Object Model", which should help:

http://msdn2.microsoft.com/en-us/library/bb386989.aspx

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Hmm... I am searching for a good technology for my new application. (Sort
of
time management on web). I thought the Validation Application Block was
good
for my business objects. And LINQ to SQL is good for getting the data from
the database. But if it is not possible to use the VAB i can't use linq.

Do you have a better solution? I like the VAB a lot. It is easy to use,
fast
to program and very sollid. With the AJAX validation controls it is also
easy
to use in the GUI.

Best regards,

Evert


Nicholas Paldino said:
Evert,

You can't through the designer. There is no way to add attributes
through the designer to the classes. You could modify the
designer-generated code, but it might be overwritten by the designer.

There is no good solution to this, I am afraid.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Does anybody know if it is possible to use the Validation Application
Block
from Enterprise Library 3.1 in Linq. The problem is that I don't know
how
to
add the validation attributes to the generated properties.

Thanks in advance,

Evert
 
Evert,

Yes, I am suggesting that you create the classes manually. The entities
that the LINQ-to-SQL designer creates aren't special in any way, and there
is nothing that is preventing you from creating them yourself. You just
have to have the proper attributes added to them which allow for the mapping
from the type to the database (the Table and Column attributes, mainly,
although I believe there are others).

The link I pointed you to should show you how to attribute your own
classes to use with a DataContext instance and execute a LINQ query to
populate instances.

Then, since you have control over the code, you can apply your own
validation attributes that you wish to apply.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Hi Nicholas,

Can you tell me what you mean with code myself? Do I need to code sort-of
copies of the LINQ entities that are created? How do I fill these
entities?
Do I need to do this manually?

Br,

Evert

Nicholas Paldino said:
Evert,

Well, there is no reason you can't code the objects that LINQ uses
yourself. You can then apply whatever attributes you wish. You can
easily
create class definitions which LINQ can use.

Here is a link to the section of the MSDN documentation titled "The
LINQ
to SQL Object Model", which should help:

http://msdn2.microsoft.com/en-us/library/bb386989.aspx

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Evert said:
Hmm... I am searching for a good technology for my new application.
(Sort
of
time management on web). I thought the Validation Application Block was
good
for my business objects. And LINQ to SQL is good for getting the data
from
the database. But if it is not possible to use the VAB i can't use
linq.

Do you have a better solution? I like the VAB a lot. It is easy to use,
fast
to program and very sollid. With the AJAX validation controls it is
also
easy
to use in the GUI.

Best regards,

Evert


:

Evert,

You can't through the designer. There is no way to add attributes
through the designer to the classes. You could modify the
designer-generated code, but it might be overwritten by the designer.

There is no good solution to this, I am afraid.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Does anybody know if it is possible to use the Validation
Application
Block
from Enterprise Library 3.1 in Linq. The problem is that I don't
know
how
to
add the validation attributes to the generated properties.

Thanks in advance,

Evert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top