private void Count()
        {
            TestContext context = new TestContext ();
            InvokeOperation<int> cnt = context.GetTest(UserID);
            cnt.Completed += new EventHandler(cnt_Completed);
        }

        void cnt_Completed(object sender, EventArgs e)
        {
            InvokeOperation<int> op = (InvokeOperation<int>)sender;
int value = op.Value;
        }
Posted by 홍상길 홍상길


[방법 1]

Context context = new Context();
LoadOperation<Movie> load = context.Load(jobcontext.MovieQuery());
List<Movie> list = load.Entities.ToList();    -- ERROR 데이터가 들어오지 않는다.
Grid.ItemsSource = load.Entities;  -- Data Binding 되어 들어간다.

[방법 2]
private void load()
{

Context context = new Context();
LoadOperation<Movie> load = context.Load(jobcontext.MovieQuery());
List<Movie> list = load.Entities.ToList();    -- ERROR 데이터가 들어오지 않는다.
Grid.ItemsSource = load.Entities;  -- Data Binding 되어 들어간다.

context .Load<Rm_rmsx_009i_3_Model>(context .MovieQuery(), DatasLoaded, false);
}

public void DatasLoaded(LoadOperation<Movie> lo)
{
     List<Rm_rmsx_009i_3_Model> list = sp3context.Rm_rmsx_009i_3_Models.ToList();
     Grid.ItemsSource = list;  -- List로 받아도 데이터가 들어간다.
}

[방법 3] 람다식을 사용해 보자.

Context context = new Context();

EntityQuery<Movie> query = context .MovieQuery();
            context .Load<Movie>(query).Completed += (sender, args) =>
            {
                List<Movie> list = ((LoadOperation<Movie>)sender).Entities.ToList();
                Grid.ItemsSource = list;   -- Succes
            };
Posted by 홍상길 홍상길

진행 순서

1. metadata 생성
    [MetadataTypeAttribute(typeof(rm_login_1_Result.rm_login_1_ResultMetadata))]
    public partial class rm_login_1_Result
    {
        internal sealed class rm_login_1_ResultMetadata
        {
            [Key]
            public string user_user { get; set; }
        }
    }

2. SP 호출
        public ObjectResult<URCSilverlight.Web.rm_login_1_Result> GetLoginCheck(string UserID, string UserPwd)
        {
            return this.ObjectContext.rm_login_1(UserID, UserPwd);
        }
Posted by 홍상길 홍상길
출처 : http://forums.silverlight.net/forums/p/168648/381609.aspx#381609

public System.Data.Objects.ObjectResult<SP1_Result> SP1()
        {
            System.Data.Objects.ObjectResult<SP1_Result> result = this.ObjectContext.SP1();
            return result;
        }

When I compile the project, I only got one error saying SP1_Result does not have a Key. So I added a SP1_Result metadata class and tagged the Key field:


[MetadataTypeAttribute(typeof(SP1_Result.SP1_ResultMetadata))]
    public partial class SP1_Result
    {
        internal sealed class SP1_ResultMetadata
        {
            [Key]
            public int MyId;
        }
    }

After this, I can compile without problem. When I checked Client Side generated code, I can see SP1_Result is generated as Entity class. DomainContext.SP1Query  and DomainContext.SP1_Results are available.

The query function also can be written as :

 public IQueryable<SP1_Result> SP1()
        {
            return this.ObjectContext.SP1().AsQueryable();            
        }

Posted by 홍상길 홍상길
원문 : http://msdn.microsoft.com/ko-kr/library/system.servicemodel.domainservices.client(VS.91).aspx

System.ServiceModel.DomainServices.Client Namespace

Provides classes that are used from the client project for interacting with domain services.

Classes

  Class Description
Public class ChangeSetEntry Represents a domain operation to be performed on an entity.
Public class DomainClient Serves as the base class for all DomainClient implementations.
Public class DomainClientResult Represents the result of a DomainClient operation.
Public class DomainContext A DomainContext is a stateful client-side representation of a domain service, providing access to all the functionality of the service.
Public class DomainException Indicates that an unrecoverable error has occurred during the execution of a domain operation.
Public class DomainOperationException Indicates that at least one error has occurred during the processing of the domain operations on the server.
Public class DomainServiceFault Provides a message type used to communicate exception results between the server and the client.
Public class Entity Base class for all entity types.
Public class EntityAction Represents a custom method invocation on an entity.
Public class EntityChangeSet Represents a collection of changes to the Entity.
Public class EntityCollection(Of TEntity) Represents a collection of associated entities.
Public class EntityCollectionChangedEventArgs(Of TEntity) Provides event arguments for strongly typed add or remove notifications for the collections that contain entities.
Public class EntityConflict Represents an entity conflict.
Public class EntityContainer Represents a cache of entities in the form of a collection of EntitySet objects.
Public class EntityKey Base class for a key that represents a unique entity identity. The key is suitable for hashing.
Public class EntityQuery Represents a query method invocation.
Public class EntityQuery(Of TEntity) Represents a LINQ query over a collection of entities.
Public class EntityQueryable Contains the static extension methods that implement a subset of the LINQ pattern for EntityQuery.
Public class EntityRef(Of TEntity) Represents a reference to an associated entity.
Public class EntitySet Represents a collection of Entity instances.
Public class EntitySet(Of TEntity) Represents a collection of Entity instances that provides change tracking and other services.
Public class InvokeArgs Represents the information required to call an invoke operation.
Public class InvokeCompletedResult Represents the result of an invoke operation.
Public class InvokeOperation Represents an asynchronous invoke operation.
Public class InvokeOperation(Of TValue) Represents an asynchronous invoke operation.
Public class LoadOperation Represents an asynchronous load operation.
Public class LoadOperation(Of TEntity) Represents an asynchronous load operation.
Public class OperationBase Represents an asynchronous operation.
Public class QueryCompletedResult Represents the result of a query operation.
Public class QueryResult Message type used to communicate query results between the server and the client.
Public class QueryResult(Of T) Message type used to communicate query results between the server and client.
Public class SubmitCompletedResult Represents the result of a submit operation.
Public class SubmitOperation Represents an asynchronous submit operation.
Public class ValidationResultInfo Contains information about the error that occurred during execution of an operation on the server.
Public class WebDomainClient(Of TContract) Provides the default domain client implementation using WCF.


Enumerations

  Enumeration Description
Public enumeration EntityOperationType Describes the types of operations that can be performed on an Entity.
Public enumeration EntitySetOperations Enumeration of the types of operations permitted on an EntitySet.
Public enumeration EntityState Describes the possible states for an Entity.
Public enumeration LoadBehavior Specifies control identity cache behavior when loading entities.
Public enumeration OperationErrorStatus Describes the errors that occur during an operation.
Posted by 홍상길 홍상길

1. DomainService 부분
        [Query]
        public IQueryable<Task> GetTasks()   // 자동생성 부분
        {
            return this.ObjectContext.Tasks;
        }

        public Task GetTask(int taskId)  // 추가된 함수 부분
        {
            return this.ObjectContext.Tasks.FirstOrDefault(t => t.TaskId == taskId);
        }



2. xaml 파일 비하인드 코드 cs 파일에 들어갈 소스
TasksDomainContext context = new TasksDomainContext();
            taskDataGrid.ItemsSource = context.Tasks;

            // 원본 Select 문에서 조건 삽입시
EntityQuery<Task> query = context.GetTasksQuery(); // LINQ 쿼리문 받아오기
LoadOperation<Task> loadOp = context.Load(query.Where(t=>t.TaskId == 1)); // 쿼리문 실행

// 조건 설정되 있는 함수 호출시
            EntityQuery<Task> p = context.GetTaskQuery(123);
            LoadOperation<Task> loadOp2 = context.Load(p);
Posted by 홍상길 홍상길
이전버튼 1 이전버튼

블로그 이미지
홍상길

공지사항

Yesterday28
Today30
Total291,201

달력

 « |  » 2019.5
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  

최근에 달린 댓글

글 보관함